pub trait EnumMapping<DB: Backend> {
// Required methods
fn map_to_database_value<'b>(
output: &mut Output<'b, '_, DB>,
variant: &'static EnumVariant,
) -> Result;
fn map_from_database_value(
raw: DB::RawValue<'_>,
type_name: &'static str,
variants: &'static [EnumVariant],
) -> Result<usize>;
}Available on crate feature
i-implement-a-third-party-backend-and-opt-into-breaking-changes only.Expand description
A helper trait to describe mapping an enum between rust values and database values
This is implemented for different mapping strategies, some of them might be database dependent, while others might be independent
Required Methods§
Sourcefn map_to_database_value<'b>(
output: &mut Output<'b, '_, DB>,
variant: &'static EnumVariant,
) -> Result
fn map_to_database_value<'b>( output: &mut Output<'b, '_, DB>, variant: &'static EnumVariant, ) -> Result
Map an enum variant to the database representation
Sourcefn map_from_database_value(
raw: DB::RawValue<'_>,
type_name: &'static str,
variants: &'static [EnumVariant],
) -> Result<usize>
fn map_from_database_value( raw: DB::RawValue<'_>, type_name: &'static str, variants: &'static [EnumVariant], ) -> Result<usize>
Construct an enum variant from the database representation
This is expected to return the index of the variant in the variants array
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl EnumMapping<Mysql> for EnumTypeMapping
Available on crate feature
mysql_backend only.impl EnumMapping<Pg> for EnumTypeMapping
Available on crate feature
postgres_backend only.impl<DB> EnumMapping<DB> for StringMapping
impl<T, ST, DB> EnumMapping<DB> for IntMapping<T, ST>
impl<T, ST> EnumMapping<Sqlite> for IntMapping<T, ST>
Available on crate feature
__sqlite-shared only.