pub trait Model:
Send
+ Sync
+ Clone
+ Debug {
type PrimaryKey: Send + Sync + Clone + Debug;
// Required methods
fn table_name() -> &'static str;
fn get_key(&self) -> Option<Self::PrimaryKey>;
fn set_key(&mut self, key: Self::PrimaryKey);
// Provided methods
fn primary_key() -> &'static str { ... }
fn fillable() -> Vec<&'static str> { ... }
fn guarded() -> Vec<&'static str> { ... }
fn hidden() -> Vec<&'static str> { ... }
fn visible() -> Vec<&'static str> { ... }
fn validate(&self) -> Result<()> { ... }
}
Expand description
Trait for data models
Required Associated Types§
Required Methods§
Sourcefn table_name() -> &'static str
fn table_name() -> &'static str
Returns the table name
Sourcefn get_key(&self) -> Option<Self::PrimaryKey>
fn get_key(&self) -> Option<Self::PrimaryKey>
Gets the primary key value
Sourcefn set_key(&mut self, key: Self::PrimaryKey)
fn set_key(&mut self, key: Self::PrimaryKey)
Sets the primary key value
Provided Methods§
Sourcefn primary_key() -> &'static str
fn primary_key() -> &'static str
Returns the primary key field name
Returns hidden fields (won’t be serialized)
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.