Trait ergol::ToTable

source ·
pub trait ToTable: Send + Debug + Sized {
    // Required methods
    fn from_row_with_offset(row: &Row, offset: usize) -> Self;
    fn table_name() -> &'static str;
    fn id_name() -> &'static str;
    fn id(&self) -> i32;
    fn create_table() -> CreateTable;
    fn drop_table() -> DropTable;
    fn select() -> Select<Self>;

    // Provided method
    fn from_row(row: &Row) -> Self { ... }
}
Expand description

Any type that should be transformed into a table should implement this trait.

You should not implement this trait yourself, and use the #ergol macro to implement this trait for your structs.

Required Methods§

source

fn from_row_with_offset(row: &Row, offset: usize) -> Self

Converts a row of a table into an object.

source

fn table_name() -> &'static str

Returns the name of the table corresponding to Self.

source

fn id_name() -> &'static str

Returns the name of the primary key of the table corresponding to Self.

source

fn id(&self) -> i32

Returns the id of self.

source

fn create_table() -> CreateTable

Returns the query that creates the table.

source

fn drop_table() -> DropTable

Returns the query that drops the table.

source

fn select() -> Select<Self>

Returns a select query.

Provided Methods§

source

fn from_row(row: &Row) -> Self

Converts a row of a table into an object.

Implementors§