Skip to main content

Record

Trait Record 

Source
pub trait Record:
    Sized
    + Send
    + Sync
    + 'static {
    type Entity: EntityTrait;

    // Required methods
    fn table_name() -> &'static str;
    fn id(&self) -> Option<i64>;
    fn record_state(&self) -> RecordState;
    fn set_record_state(&mut self, state: RecordState);
    fn from_sea_model(model: <Self::Entity as EntityTrait>::Model) -> Self;
    fn to_active_model(&self) -> <Self::Entity as EntityTrait>::ActiveModel
       where <Self::Entity as EntityTrait>::ActiveModel: ActiveModelTrait;

    // Provided methods
    fn primary_key_name() -> &'static str { ... }
    fn new_record(&self) -> bool { ... }
    fn persisted(&self) -> bool { ... }
    fn destroyed(&self) -> bool { ... }
}
Expand description

Bridges a RustRails record wrapper to its SeaORM entity.

Required Associated Types§

Source

type Entity: EntityTrait

The SeaORM entity backing this record type.

Required Methods§

Source

fn table_name() -> &'static str

Returns the database table name.

Source

fn id(&self) -> Option<i64>

Returns the primary key value when present.

Source

fn record_state(&self) -> RecordState

Returns the current lifecycle state.

Source

fn set_record_state(&mut self, state: RecordState)

Updates the lifecycle state.

Source

fn from_sea_model(model: <Self::Entity as EntityTrait>::Model) -> Self

Builds the record wrapper from a SeaORM model.

Source

fn to_active_model(&self) -> <Self::Entity as EntityTrait>::ActiveModel

Converts the record wrapper into a SeaORM active model.

Provided Methods§

Source

fn primary_key_name() -> &'static str

Returns the primary key column name.

Source

fn new_record(&self) -> bool

Returns true when the record has not been persisted yet.

Source

fn persisted(&self) -> bool

Returns true when the record exists in the database.

Source

fn destroyed(&self) -> bool

Returns true when the record has been destroyed.

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§