Trait microrm::entity::Entity

source ·
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§

source

type ID: EntityID

source

type IDColumn: EntityColumn<Entity = Self>

Required Methods§

source

fn table_name() -> &'static str

source

fn column_count() -> usize
where Self: Sized,

source

fn columns() -> &'static [&'static dyn EntityColumn<Entity = Self>]

source

fn id_column() -> Self::IDColumn

source

fn visit_values<E, F: FnMut(&dyn Modelable) -> Result<(), E>>( &self, visit: &mut F ) -> Result<(), E>

source

fn build_from(stmt: &Statement<'_>) -> Result<Self>
where Self: Sized,

Provided Methods§

Object Safety§

This trait is not object safe.

Implementors§