Last active
October 25, 2019 13:09
-
-
Save dutchmartin/574296f7d52501a6522027b2a34aef48 to your computer and use it in GitHub Desktop.
sprattus traits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub trait FromSql { | |
fn from_row(row: &Row) -> Result<Self, Error> | |
where | |
Self: Sized; | |
} | |
pub trait ToSql { | |
type PK; | |
fn get_primary_key_value(&self) -> Self::PK | |
where | |
Self::PK: ToSqlItem + Sized + Sync; | |
fn get_table_name() -> &'static str; | |
fn get_primary_key() -> &'static str; | |
fn get_fields() -> &'static str; | |
fn get_all_fields() -> &'static str; | |
fn get_values_of_all_fields(&self) -> Vec<&(dyn ToSqlItem + Sync)>; | |
fn get_query_params(&self) -> Vec<&(dyn ToSqlItem + Sync)>; | |
fn get_prepared_arguments_list() -> &'static str; | |
fn get_prepared_arguments_list_with_types() -> &'static str; | |
fn get_argument_count() -> usize; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment