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§
Sourcetype Entity: EntityTrait
type Entity: EntityTrait
The SeaORM entity backing this record type.
Required Methods§
Sourcefn table_name() -> &'static str
fn table_name() -> &'static str
Returns the database table name.
Sourcefn record_state(&self) -> RecordState
fn record_state(&self) -> RecordState
Returns the current lifecycle state.
Sourcefn set_record_state(&mut self, state: RecordState)
fn set_record_state(&mut self, state: RecordState)
Updates the lifecycle state.
Sourcefn from_sea_model(model: <Self::Entity as EntityTrait>::Model) -> Self
fn from_sea_model(model: <Self::Entity as EntityTrait>::Model) -> Self
Builds the record wrapper from a SeaORM model.
Sourcefn to_active_model(&self) -> <Self::Entity as EntityTrait>::ActiveModel
fn to_active_model(&self) -> <Self::Entity as EntityTrait>::ActiveModel
Converts the record wrapper into a SeaORM active model.
Provided Methods§
Sourcefn primary_key_name() -> &'static str
fn primary_key_name() -> &'static str
Returns the primary key column name.
Sourcefn new_record(&self) -> bool
fn new_record(&self) -> bool
Returns true when the record has not been persisted yet.
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.