pub struct SchemaGenerator { /* private fields */ }Expand description
生成器:把表元数据列表转换成 schema.rs 文件内容
Implementations§
Source§impl SchemaGenerator
impl SchemaGenerator
Sourcepub fn with_crate_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_crate_prefix(self, prefix: impl Into<String>) -> Self
P1-7:自定义生成代码中的 crate 前缀。
默认 "sz_orm_core";若项目直接依赖 sz_orm_query,
可设为 "sz_orm_query" 使生成的 use 语句与项目依赖对齐。
Sourcepub fn with_header(self, header: impl Into<String>) -> Self
pub fn with_header(self, header: impl Into<String>) -> Self
自定义文件头注释
Sourcepub fn emit_model_structs(self, emit: bool) -> Self
pub fn emit_model_structs(self, emit: bool) -> Self
Sourcepub fn with_model_derives(self, derives: impl Into<String>) -> Self
pub fn with_model_derives(self, derives: impl Into<String>) -> Self
#41 修复:自定义 Model struct 的派生属性
默认为 "Debug, Clone, serde::Serialize, serde::Deserialize"。
传入空字符串则不生成 #[derive(...)] 属性。
Sourcepub fn generate(&self, tables: &[TableSchema]) -> String
pub fn generate(&self, tables: &[TableSchema]) -> String
生成完整的 schema.rs 文件内容
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SchemaGenerator
impl RefUnwindSafe for SchemaGenerator
impl Send for SchemaGenerator
impl Sync for SchemaGenerator
impl Unpin for SchemaGenerator
impl UnsafeUnpin for SchemaGenerator
impl UnwindSafe for SchemaGenerator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more