SqlStruct

Trait SqlStruct 

Source
pub trait SqlStruct: Sized {
    const FIELDS: &'static [FieldMeta];

    // Required methods
    fn values(&self) -> Vec<Arg>;
    fn is_empty_field(&self, rust_field: &'static str) -> bool;
    fn addr_cells<'a>(
        &'a mut self,
        rust_fields: &[&'static str],
    ) -> Option<Vec<ScanCell<'a>>>;
}
Expand description

由宏为你的业务 struct 实现的 trait:提供字段元数据与取值/空值判断。

Required Associated Constants§

Source

const FIELDS: &'static [FieldMeta]

Required Methods§

Source

fn values(&self) -> Vec<Arg>

取字段的值用于 INSERT/UPDATE(按 FIELDS 顺序)。

Source

fn is_empty_field(&self, rust_field: &'static str) -> bool

判断某个字段是否“空值”(用于 omitempty)。

Source

fn addr_cells<'a>( &'a mut self, rust_fields: &[&'static str], ) -> Option<Vec<ScanCell<'a>>>

返回可写入的扫描目标列表(用于 Struct::addr*)。

说明:为了避免 Rust 借用检查器对“多次可变借用同一 struct”的限制, 这里一次性生成全部 ScanCell(内部用 raw pointer 持有字段地址)。

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§