IdGenerator

Trait IdGenerator 

Source
pub trait IdGenerator<Id: IdType, DbId: PostgresIdType>: Send + Sync {
    // Required methods
    fn create_statement_column_type(&self) -> &str;
    fn generate_id(&self) -> Option<DbId>;
    fn id_to_db_id<'a>(
        &self,
        id: Cow<'a, Id>,
    ) -> Result<Cow<'a, DbId>, C3p0Error>;
    fn db_id_to_id<'a>(
        &self,
        id: Cow<'a, DbId>,
    ) -> Result<Cow<'a, Id>, C3p0Error>;
}
Expand description

A trait that allows the creation of an Id

Required Methods§

Source

fn create_statement_column_type(&self) -> &str

Returns the column type for the id in the create statement

Source

fn generate_id(&self) -> Option<DbId>

Generates a new id

Source

fn id_to_db_id<'a>(&self, id: Cow<'a, Id>) -> Result<Cow<'a, DbId>, C3p0Error>

Converts an Id to a DbId

Source

fn db_id_to_id<'a>(&self, id: Cow<'a, DbId>) -> Result<Cow<'a, Id>, C3p0Error>

Converts a DbId to an Id

Implementors§