Skip to main content

PostgresEnum

Trait PostgresEnum 

Source
pub trait PostgresEnum: Sized {
    const PG_TYPE_NAME: &'static str;

    // Required methods
    fn to_label(&self) -> &'static str;
    fn from_label(label: &str) -> Result<Self, Box<dyn Error + Sync + Send>>;
}
Expand description

Trait implemented by Rust enums that map to PostgreSQL enum types.

Can be implemented manually or via the #[derive(PostgresEnum)] macro.

Required Associated Constants§

Source

const PG_TYPE_NAME: &'static str

The PostgreSQL type name (e.g., “mood”). Schema-qualify if needed (e.g., “public.mood”).

Required Methods§

Source

fn to_label(&self) -> &'static str

Convert this variant to its PostgreSQL label string.

Source

fn from_label(label: &str) -> Result<Self, Box<dyn Error + Sync + Send>>

Parse a PostgreSQL label string into a variant.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§