crates/laymesh-core/src/lib.rs 1pub mod assets;2mod collections;3pub mod color;4pub mod colormap;5mod data;6pub mod endpoints;7pub mod engine;8mod formatting;9pub mod geometry;10pub mod geometry_query;11mod geometry_recipe;12pub mod migration;13pub mod model;14pub mod parser;15pub mod plot;16mod query_path;17pub mod style;18pub mod text;19mod validation;20use serde::{Deserialize, Serialize};21 22#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, PartialEq)]23pub struct Loc {24 pub line: usize,25 pub column: usize,26 pub offset: usize,27}28#[derive(Clone, Debug, Serialize, Deserialize)]29pub struct Diagnostic {30 pub code: String,31 pub message: String,32 pub file: String,33 pub loc: Loc,34}35impl Diagnostic {36 pub fn new(code: &str, message: impl Into<String>, file: &str, loc: Loc) -> Self {37 Self {38 code: code.into(),39 message: message.into(),40 file: file.into(),41 loc,42 }43 }44}45impl std::fmt::Display for Diagnostic {46 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {47 write!(48 f,49 "{}:{}:{}: {}: {}",50 self.file, self.loc.line, self.loc.column, self.code, self.message51 )52 }53}54impl std::error::Error for Diagnostic {}55pub type Result<T> = std::result::Result<T, Diagnostic>;