pub trait Entity: 'static + for<'de> Deserialize<'de> + Serialize {
type ID: EntityID;
type IDColumn: EntityColumn<Entity = Self>;
// Required methods
fn table_name() -> &'static str;
fn column_count() -> usize
where Self: Sized;
fn columns() -> &'static [&'static dyn EntityColumn<Entity = Self>];
fn id_column() -> Self::IDColumn;
fn visit_values<E, F: FnMut(&dyn Modelable) -> Result<(), E>>(
&self,
visit: &mut F
) -> Result<(), E>;
fn build_from(stmt: &Statement<'_>) -> Result<Self>
where Self: Sized;
// Provided method
fn constraints<CV: ConstraintVisitor>(_cv: &mut CV) { ... }
}
Expand description
A database entity, aka a struct representing a row in a table
Required Associated Types§
Required Methods§
fn table_name() -> &'static str
fn column_count() -> usizewhere
Self: Sized,
fn columns() -> &'static [&'static dyn EntityColumn<Entity = Self>]
fn id_column() -> Self::IDColumn
fn visit_values<E, F: FnMut(&dyn Modelable) -> Result<(), E>>( &self, visit: &mut F ) -> Result<(), E>
fn build_from(stmt: &Statement<'_>) -> Result<Self>where
Self: Sized,
Provided Methods§
fn constraints<CV: ConstraintVisitor>(_cv: &mut CV)
Object Safety§
This trait is not object safe.