Skip to main content

ModelValues

Trait ModelValues 

Source
pub trait ModelValues {
    // Required methods
    fn field_values(&self) -> Vec<(&'static str, SqlValue)>;
    fn pk_value(&self) -> SqlValue;
    fn pk_column() -> &'static str;

    // Provided method
    fn set_generated_pk(&mut self, _id: i64) { ... }
}
Expand description

Implemented by #[derive(Model)] — provides field names + values for INSERT/UPDATE.

Required Methods§

Source

fn field_values(&self) -> Vec<(&'static str, SqlValue)>

Returns (column_name, value) pairs for all non-PK fields.

Source

fn pk_value(&self) -> SqlValue

Returns the primary key value.

Source

fn pk_column() -> &'static str

Returns the primary key column name.

Provided Methods§

Source

fn set_generated_pk(&mut self, _id: i64)

Stores a database-generated primary key (auto-increment PKs only; no-op otherwise). Used by backends without RETURNING (MySQL).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§