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§
sourcefn from_row_with_offset(row: &Row, offset: usize) -> Self
fn from_row_with_offset(row: &Row, offset: usize) -> Self
Converts a row of a table into an object.
sourcefn table_name() -> &'static str
fn table_name() -> &'static str
Returns the name of the table corresponding to Self.
sourcefn id_name() -> &'static str
fn id_name() -> &'static str
Returns the name of the primary key of the table corresponding to Self.
sourcefn create_table() -> CreateTable
fn create_table() -> CreateTable
Returns the query that creates the table.
sourcefn drop_table() -> DropTable
fn drop_table() -> DropTable
Returns the query that drops the table.