Trait Model

Source
pub trait Model {
    // Required methods
    fn table_name() -> &'static str;
    fn columns() -> &'static [Column<'static>];
    fn count_columns() -> usize;
    fn get_id(&self) -> i64;
    fn id_column() -> Column<'static>;
    fn column_value(
        &self,
        column: &'static Column<'static>,
    ) -> Option<Box<dyn ToSql>>;
    fn parse_rows(
        rows: Rows<'_>,
        offset: usize,
        joins: &Vec<String>,
    ) -> Vec<Self>
       where Self: Sized;
    fn parse_row(row: &Row<'_>, offset: usize, joins: &Vec<String>) -> Self
       where Self: Sized;
}
Expand description

A trait that needs to be implemented for all models that are used with sequelite.

This trait is hard to implement manually, so it is automatically implemented for every struct that derives Model.

§Note

This trait is not meant to be implemented manually.

Required Methods§

Source

fn table_name() -> &'static str

Source

fn columns() -> &'static [Column<'static>]

Source

fn count_columns() -> usize

Source

fn get_id(&self) -> i64

Source

fn id_column() -> Column<'static>

Source

fn column_value( &self, column: &'static Column<'static>, ) -> Option<Box<dyn ToSql>>

Source

fn parse_rows(rows: Rows<'_>, offset: usize, joins: &Vec<String>) -> Vec<Self>
where Self: Sized,

Source

fn parse_row(row: &Row<'_>, offset: usize, joins: &Vec<String>) -> Self
where Self: Sized,

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§