Skip to main content

EnumSqlType

Trait EnumSqlType 

Source
pub trait EnumSqlType<const HAS_EXPLICIT_DISCRIMINANT: bool, DB: Backend>: SqlType {
    type Strategy: EnumMapping<DB>;
}
Expand description

A marker trait for SQL types representing database side enums

This trait describes how an enum should be mapped to the underlying database storage type by specifying one of a set of different strategies.

The generic constant HAS_EXPLICIT_DISCRIMINANT can be used to enforce that for a given mapping the user needs to provide explicit discriminant values. The #[derive(Enum)] macro will pass the true only if this is the case.

The generic type DB represents the database backend for which this mapping is valid

§Deriving

This trait can be automatically derived by using #[derive(SqlType)] with the #[diesel(enum_type)] attribute

Required Associated Types§

Source

type Strategy: EnumMapping<DB>

The mapping strategy used by this type

This mainly exists to share the logic between different SQL types

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<DB> EnumSqlType<true, DB> for BigInt
where DB: Backend, IntMapping<i64, Self>: EnumMapping<DB>,

Source§

type Strategy = IntMapping<i64, BigInt>

Source§

impl<DB> EnumSqlType<true, DB> for Integer
where DB: Backend, IntMapping<i32, Self>: EnumMapping<DB>,

Source§

type Strategy = IntMapping<i32, Integer>

Source§

impl<DB> EnumSqlType<true, DB> for SmallInt
where DB: Backend, IntMapping<i16, Self>: EnumMapping<DB>,

Source§

type Strategy = IntMapping<i16, SmallInt>

Source§

impl<DB> EnumSqlType<true, DB> for TinyInt
where DB: Backend, IntMapping<i8, Self>: EnumMapping<DB>,

Source§

type Strategy = IntMapping<i8, TinyInt>

Source§

impl<const ANYWAY: bool, DB> EnumSqlType<ANYWAY, DB> for Text
where DB: Backend, StringMapping: EnumMapping<DB>,

Source§

type Strategy = StringMapping