SqlEnum

Trait SqlEnum 

Source
pub trait SqlEnum:
    Sized
    + 'static
    + Clone {
    type IntegerType: Display + TryInto<usize> + IntoSqlType;

    const ENUM_NAME: &'static str;
    const VARIANTS_IN_ORDER: &'static [Self];

    // Required method
    fn to_integer(self) -> Self::IntegerType;

    // Provided method
    fn from_integer(integer: Self::IntegerType) -> Result<Self> { ... }
}
Expand description

An enum consisting of only empty variants, backed up by an integer type, which can be used in sql statements.

Required Associated Constants§

Source

const ENUM_NAME: &'static str

Source

const VARIANTS_IN_ORDER: &'static [Self]

The variants of the enum, in order.

Required Associated Types§

Source

type IntegerType: Display + TryInto<usize> + IntoSqlType

The smallest integer type needed to represent this enum.

Required Methods§

Source

fn to_integer(self) -> Self::IntegerType

Converts a variant of this enum to an integer.

Provided Methods§

Source

fn from_integer(integer: Self::IntegerType) -> Result<Self>

Converts an integer to a variant of this enum.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§