pub struct Struct<T: SqlStruct> {
pub flavor: Flavor,
/* private fields */
}Fields§
§flavor: FlavorImplementations§
Source§impl<T: SqlStruct> Struct<T>
impl<T: SqlStruct> Struct<T>
pub fn new() -> Self
Sourcepub fn with_field_mapper(&self, mapper: FieldMapperFunc) -> Self
pub fn with_field_mapper(&self, mapper: FieldMapperFunc) -> Self
WithFieldMapper:返回 shadow copy,并覆盖当前 Struct 的 mapper(对齐 go Struct.WithFieldMapper)。
- 传入
identity_mapper()等价于 go 的WithFieldMapper(nil)。
Sourcepub fn for_flavor(&self, flavor: Flavor) -> Self
pub fn for_flavor(&self, flavor: Flavor) -> Self
ForFlavor:返回 shadow copy(对齐 go Struct.For),不修改原对象。
Sourcepub fn with_tag(&self, tags: impl IntoIterator<Item = &'static str>) -> Self
pub fn with_tag(&self, tags: impl IntoIterator<Item = &'static str>) -> Self
WithTag:返回 shadow copy(对齐 go Struct.WithTag),不修改原对象。
Sourcepub fn without_tag(&self, tags: impl IntoIterator<Item = &'static str>) -> Self
pub fn without_tag(&self, tags: impl IntoIterator<Item = &'static str>) -> Self
WithoutTag:返回 shadow copy(对齐 go Struct.WithoutTag),不修改原对象。
Sourcepub fn columns(&self) -> Vec<String>
pub fn columns(&self) -> Vec<String>
Columns:对齐 go-sqlbuilder Struct.Columns()(返回 ForWrite 的未 quote 列名)。
Sourcepub fn columns_for_tag(&self, tag: &str) -> Option<Vec<String>>
pub fn columns_for_tag(&self, tag: &str) -> Option<Vec<String>>
ColumnsForTag:对齐 go-sqlbuilder Struct.ColumnsForTag(tag)。
- 如果 tag 不存在,返回 None(对齐 go 返回 nil)
Sourcepub fn values(&self, v: &T) -> Vec<Arg>
pub fn values(&self, v: &T) -> Vec<Arg>
Values:对齐 go-sqlbuilder Struct.Values()(返回 ForWrite 的值,顺序与 columns() 一致)。
Sourcepub fn values_for_tag(&self, tag: &str, v: &T) -> Option<Vec<Arg>>
pub fn values_for_tag(&self, tag: &str, v: &T) -> Option<Vec<Arg>>
ValuesForTag:对齐 go-sqlbuilder Struct.ValuesForTag(tag, value)。
- 如果 tag 不存在,返回 None(对齐 go 返回 nil)
Sourcepub fn foreach_read(&self, trans: impl FnMut(&str, bool, &FieldMeta))
pub fn foreach_read(&self, trans: impl FnMut(&str, bool, &FieldMeta))
ForeachRead:对齐 go-sqlbuilder Struct.ForeachRead。
dbtag:等价 go 的sf.DBTag(可能为空字符串)is_quoted:等价 go 的sf.IsQuotedfield_meta:Rust 侧提供的字段元信息(替代 go 的reflect.StructField)
Sourcepub fn foreach_write(&self, trans: impl FnMut(&str, bool, &FieldMeta))
pub fn foreach_write(&self, trans: impl FnMut(&str, bool, &FieldMeta))
ForeachWrite:对齐 go-sqlbuilder Struct.ForeachWrite。
Sourcepub fn addr<'a>(&self, st: &'a mut T) -> Vec<ScanCell<'a>>
pub fn addr<'a>(&self, st: &'a mut T) -> Vec<ScanCell<'a>>
Addr:对齐 go-sqlbuilder Struct.Addr(st)(返回 ForRead 的“写入目标”列表)。
Sourcepub fn addr_for_tag<'a>(
&self,
tag: &str,
st: &'a mut T,
) -> Option<Vec<ScanCell<'a>>>
pub fn addr_for_tag<'a>( &self, tag: &str, st: &'a mut T, ) -> Option<Vec<ScanCell<'a>>>
AddrForTag:对齐 go-sqlbuilder Struct.AddrForTag(tag, st)。
tag 不存在返回 None(对齐 go 返回 nil)。
Sourcepub fn addr_with_cols<'a>(
&self,
cols: &[&str],
st: &'a mut T,
) -> Option<Vec<ScanCell<'a>>>
pub fn addr_with_cols<'a>( &self, cols: &[&str], st: &'a mut T, ) -> Option<Vec<ScanCell<'a>>>
AddrWithCols:对齐 go-sqlbuilder Struct.AddrWithCols(cols, st)。
如果 cols 中任一列找不到,返回 None(对齐 go 返回 nil)。
pub fn select_from(&self, table: &str) -> SelectBuilder
Sourcepub fn select_from_for_tag(&self, table: &str, tag: &str) -> SelectBuilder
pub fn select_from_for_tag(&self, table: &str, tag: &str) -> SelectBuilder
SelectFromForTag:对齐 go-sqlbuilder SelectFromForTag(table, tag)(deprecated)。
pub fn update(&self, table: &str, value: &T) -> UpdateBuilder
Sourcepub fn update_for_tag(&self, table: &str, tag: &str, value: &T) -> UpdateBuilder
pub fn update_for_tag(&self, table: &str, tag: &str, value: &T) -> UpdateBuilder
UpdateForTag:对齐 go-sqlbuilder UpdateForTag(table, tag, value)(deprecated)。
pub fn delete_from(&self, table: &str) -> DeleteBuilder
pub fn insert_into<'a>(
&self,
table: &str,
rows: impl IntoIterator<Item = &'a T>,
) -> InsertBuilderwhere
T: 'a,
Sourcepub fn insert_into_for_tag<'a>(
&self,
table: &str,
tag: &str,
rows: impl IntoIterator<Item = &'a T>,
) -> InsertBuilderwhere
T: 'a,
pub fn insert_into_for_tag<'a>(
&self,
table: &str,
tag: &str,
rows: impl IntoIterator<Item = &'a T>,
) -> InsertBuilderwhere
T: 'a,
InsertIntoForTag:对齐 go-sqlbuilder InsertIntoForTag(table, tag, value...)(deprecated)。
pub fn insert_ignore_into_for_tag<'a>(
&self,
table: &str,
tag: &str,
rows: impl IntoIterator<Item = &'a T>,
) -> InsertBuilderwhere
T: 'a,
pub fn replace_into_for_tag<'a>(
&self,
table: &str,
tag: &str,
rows: impl IntoIterator<Item = &'a T>,
) -> InsertBuilderwhere
T: 'a,
Sourcepub fn insert_into_any<'a>(
&self,
table: &str,
values: impl IntoIterator<Item = &'a dyn Any>,
) -> InsertBuilderwhere
T: 'static,
pub fn insert_into_any<'a>(
&self,
table: &str,
values: impl IntoIterator<Item = &'a dyn Any>,
) -> InsertBuilderwhere
T: 'static,
InsertIntoAny:对齐 go InsertInto(table, value ...interface{}) 的“忽略非预期类型”语义。