pub struct SchemaGenerator { /* private fields */ }Expand description
生成器:把表元数据列表转换成 schema.rs 文件内容
Implementations§
Source§impl SchemaGenerator
impl SchemaGenerator
Sourcepub fn new() -> SchemaGenerator
pub fn new() -> SchemaGenerator
创建新的生成器
Sourcepub fn with_crate_prefix(self, prefix: impl Into<String>) -> SchemaGenerator
pub fn with_crate_prefix(self, prefix: impl Into<String>) -> SchemaGenerator
P1-7:自定义生成代码中的 crate 前缀。
默认 "sz_orm_core";若项目直接依赖 sz_orm_query,
可设为 "sz_orm_query" 使生成的 use 语句与项目依赖对齐。
Sourcepub fn with_header(self, header: impl Into<String>) -> SchemaGenerator
pub fn with_header(self, header: impl Into<String>) -> SchemaGenerator
自定义文件头注释
Sourcepub fn emit_use(self, emit: bool) -> SchemaGenerator
pub fn emit_use(self, emit: bool) -> SchemaGenerator
是否生成 use sz_orm_migration::typed_query; 语句
Sourcepub fn emit_model_structs(self, emit: bool) -> SchemaGenerator
pub fn emit_model_structs(self, emit: bool) -> SchemaGenerator
Sourcepub fn with_model_derives(self, derives: impl Into<String>) -> SchemaGenerator
pub fn with_model_derives(self, derives: impl Into<String>) -> SchemaGenerator
#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§
Source§impl Default for SchemaGenerator
impl Default for SchemaGenerator
Source§fn default() -> SchemaGenerator
fn default() -> SchemaGenerator
Returns the “default value” for a type. Read more
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more