pub trait ModelExt: Model {
Show 14 methods
// Required methods
fn columns() -> Vec<&'static str>;
fn fillable() -> Vec<&'static str>;
// Provided methods
fn guarded() -> Vec<&'static str> { ... }
fn hidden() -> Vec<&'static str> { ... }
fn visible() -> Vec<&'static str> { ... }
fn casts() -> HashMap<&'static str, &'static str> { ... }
fn dates() -> Vec<&'static str> { ... }
fn date_format(_field: &str) -> Option<&'static str> { ... }
fn relations() -> HashMap<&'static str, Relation> { ... }
fn to_value(&self) -> HashMap<String, Value> { ... }
fn get_column_value(&self, _column: &str) -> Option<Value> { ... }
fn from_value(&mut self, _map: HashMap<String, Value>) { ... }
fn fill(&mut self, map: HashMap<String, Value>) { ... }
fn to_json(&self) -> Value { ... }
}Expand description
模型扩展 trait,提供额外功能
Required Methods§
Provided Methods§
获取隐藏列(不参与序列化)
Sourcefn date_format(_field: &str) -> Option<&'static str>
fn date_format(_field: &str) -> Option<&'static str>
获取指定字段的日期格式
Sourcefn get_column_value(&self, _column: &str) -> Option<Value>
fn get_column_value(&self, _column: &str) -> Option<Value>
获取指定列的值(须由实现重写)
Sourcefn from_value(&mut self, _map: HashMap<String, Value>)
fn from_value(&mut self, _map: HashMap<String, Value>)
从值映射还原模型(须由实现重写)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".