初始化工程

This commit is contained in:
2025-07-15 15:33:35 +08:00
parent ead49da3e8
commit bbd78128d0
301 changed files with 23953 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
pub mod prelude{
pub use crate::*;
{{~ for ns in __ns ~}}
pub use {{ns}}::*;
{{~end~}}
}
{{~ if __polymorphic_beans.count != 0 ~}}
type AbstractBase = dyn std::any::Any + Sync + Send;
pub trait GetBase<'a, T> {
fn get_base(&'a self) -> Result<T, LubanError>;
}
{{~end~}}
#[derive(Debug)]
pub enum LubanError {
Loader(String),
Table(String),
Bean(String),
Polymorphic(String),
Unknown(String),
}
impl std::fmt::Display for LubanError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
LubanError::Loader(msg) |
LubanError::Table(msg) |
LubanError::Bean(msg) |
LubanError::Polymorphic(msg) |
LubanError::Unknown(msg) => msg,
})
}
}
pub struct Tables{
{{~ for table in __tables ~}}
pub {{table.name}}: std::sync::Arc<{{full_name table}}>,
{{~end~}}
}
impl Tables {
pub fn new<T: Fn(&str) -> Result<serde_json::Value, LubanError>>(loader: T) -> Result<Tables, LubanError> {
Ok(Tables {
{{~ for table in __tables ~}}
{{table.name}}: {{full_name table}}::new(&loader("{{table.output_data_file}}")?)?,
{{~end~}}
})
}
}