Struct

Struct Struct 

Source
pub struct Struct<T: SqlStruct> {
    pub flavor: Flavor,
    /* private fields */
}

Fields§

§flavor: Flavor

Implementations§

Source§

impl<T: SqlStruct> Struct<T>

Source

pub fn new() -> Self

Source

pub fn with_field_mapper(&self, mapper: FieldMapperFunc) -> Self

WithFieldMapper:返回 shadow copy,并覆盖当前 Struct 的 mapper(对齐 go Struct.WithFieldMapper)。

  • 传入 identity_mapper() 等价于 go 的 WithFieldMapper(nil)
Source

pub fn for_flavor(&self, flavor: Flavor) -> Self

ForFlavor:返回 shadow copy(对齐 go Struct.For),不修改原对象。

Source

pub fn with_tag(&self, tags: impl IntoIterator<Item = &'static str>) -> Self

WithTag:返回 shadow copy(对齐 go Struct.WithTag),不修改原对象。

Source

pub fn without_tag(&self, tags: impl IntoIterator<Item = &'static str>) -> Self

WithoutTag:返回 shadow copy(对齐 go Struct.WithoutTag),不修改原对象。

Source

pub fn columns(&self) -> Vec<String>

Columns:对齐 go-sqlbuilder Struct.Columns()(返回 ForWrite 的未 quote 列名)。

Source

pub fn columns_for_tag(&self, tag: &str) -> Option<Vec<String>>

ColumnsForTag:对齐 go-sqlbuilder Struct.ColumnsForTag(tag)

  • 如果 tag 不存在,返回 None(对齐 go 返回 nil)
Source

pub fn values(&self, v: &T) -> Vec<Arg>

Values:对齐 go-sqlbuilder Struct.Values()(返回 ForWrite 的值,顺序与 columns() 一致)。

Source

pub fn values_for_tag(&self, tag: &str, v: &T) -> Option<Vec<Arg>>

ValuesForTag:对齐 go-sqlbuilder Struct.ValuesForTag(tag, value)

  • 如果 tag 不存在,返回 None(对齐 go 返回 nil)
Source

pub fn foreach_read(&self, trans: impl FnMut(&str, bool, &FieldMeta))

ForeachRead:对齐 go-sqlbuilder Struct.ForeachRead

  • dbtag:等价 go 的 sf.DBTag(可能为空字符串)
  • is_quoted:等价 go 的 sf.IsQuoted
  • field_meta:Rust 侧提供的字段元信息(替代 go 的 reflect.StructField
Source

pub fn foreach_write(&self, trans: impl FnMut(&str, bool, &FieldMeta))

ForeachWrite:对齐 go-sqlbuilder Struct.ForeachWrite

Source

pub fn addr<'a>(&self, st: &'a mut T) -> Vec<ScanCell<'a>>

Addr:对齐 go-sqlbuilder Struct.Addr(st)(返回 ForRead 的“写入目标”列表)。

Source

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)。

Source

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)。

Source

pub fn select_from(&self, table: &str) -> SelectBuilder

Source

pub fn select_from_for_tag(&self, table: &str, tag: &str) -> SelectBuilder

SelectFromForTag:对齐 go-sqlbuilder SelectFromForTag(table, tag)(deprecated)。

Source

pub fn update(&self, table: &str, value: &T) -> UpdateBuilder

Source

pub fn update_for_tag(&self, table: &str, tag: &str, value: &T) -> UpdateBuilder

UpdateForTag:对齐 go-sqlbuilder UpdateForTag(table, tag, value)(deprecated)。

Source

pub fn delete_from(&self, table: &str) -> DeleteBuilder

Source

pub fn insert_into<'a>( &self, table: &str, rows: impl IntoIterator<Item = &'a T>, ) -> InsertBuilder
where T: 'a,

Source

pub fn insert_into_for_tag<'a>( &self, table: &str, tag: &str, rows: impl IntoIterator<Item = &'a T>, ) -> InsertBuilder
where T: 'a,

InsertIntoForTag:对齐 go-sqlbuilder InsertIntoForTag(table, tag, value...)(deprecated)。

Source

pub fn insert_ignore_into_for_tag<'a>( &self, table: &str, tag: &str, rows: impl IntoIterator<Item = &'a T>, ) -> InsertBuilder
where T: 'a,

Source

pub fn replace_into_for_tag<'a>( &self, table: &str, tag: &str, rows: impl IntoIterator<Item = &'a T>, ) -> InsertBuilder
where T: 'a,

Source

pub fn insert_into_any<'a>( &self, table: &str, values: impl IntoIterator<Item = &'a dyn Any>, ) -> InsertBuilder
where T: 'static,

InsertIntoAny:对齐 go InsertInto(table, value ...interface{}) 的“忽略非预期类型”语义。

Source

pub fn insert_ignore_into_any<'a>( &self, table: &str, values: impl IntoIterator<Item = &'a dyn Any>, ) -> InsertBuilder
where T: 'static,

Source

pub fn replace_into_any<'a>( &self, table: &str, values: impl IntoIterator<Item = &'a dyn Any>, ) -> InsertBuilder
where T: 'static,

Source

pub fn insert_into_for_tag_any<'a>( &self, table: &str, tag: &str, values: impl IntoIterator<Item = &'a dyn Any>, ) -> InsertBuilder
where T: 'static,

Source

pub fn insert_ignore_into_for_tag_any<'a>( &self, table: &str, tag: &str, values: impl IntoIterator<Item = &'a dyn Any>, ) -> InsertBuilder
where T: 'static,

Source

pub fn replace_into_for_tag_any<'a>( &self, table: &str, tag: &str, values: impl IntoIterator<Item = &'a dyn Any>, ) -> InsertBuilder
where T: 'static,

Source

pub fn insert_ignore_into<'a>( &self, table: &str, rows: impl IntoIterator<Item = &'a T>, ) -> InsertBuilder
where T: 'a,

Source

pub fn replace_into<'a>( &self, table: &str, rows: impl IntoIterator<Item = &'a T>, ) -> InsertBuilder
where T: 'a,

Trait Implementations§

Source§

impl<T: SqlStruct> Clone for Struct<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: SqlStruct> Debug for Struct<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: SqlStruct> Default for Struct<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Struct<T>

§

impl<T> !RefUnwindSafe for Struct<T>

§

impl<T> Send for Struct<T>
where T: Send,

§

impl<T> Sync for Struct<T>
where T: Sync,

§

impl<T> Unpin for Struct<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Struct<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.