pub trait Model:
Sized
+ Send
+ Sync {
// Required methods
fn table_name() -> &'static str;
fn column_names() -> &'static [&'static str];
fn primary_key_name() -> &'static str;
fn primary_key_value(&self) -> Value;
fn from_row(row: &ModelRow) -> Result<Self, DbError>;
fn to_values(&self) -> Vec<(&'static str, Value)>;
// Provided method
fn primary_key_auto_increment() -> bool { ... }
}Available on crate features
model-mysql or model-postgres or model-sqlite only.Expand description
Trait generated by #[derive(Model)]. Maps a Rust struct to a database table.
Required Methods§
Sourcefn table_name() -> &'static str
fn table_name() -> &'static str
The database table name.
Sourcefn column_names() -> &'static [&'static str]
fn column_names() -> &'static [&'static str]
All column names (excluding #[ignore] fields).
Sourcefn primary_key_name() -> &'static str
fn primary_key_name() -> &'static str
The primary key column name.
Sourcefn primary_key_value(&self) -> Value
fn primary_key_value(&self) -> Value
The primary key value for this instance.
Provided Methods§
Sourcefn primary_key_auto_increment() -> bool
fn primary_key_auto_increment() -> bool
Whether the primary key is auto-incremented by the database.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".