Skip to main content

PostgresEnum

Trait PostgresEnum 

Source
pub trait PostgresEnum:
    Send
    + Sync
    + Any {
    // Required methods
    fn enum_type_name(&self) -> &'static str;
    fn as_enum(&self) -> &dyn PostgresEnum;
    fn variant_name(&self) -> &'static str;
    fn into_boxed(&self) -> Box<dyn PostgresEnum>;
    fn try_from_str(value: &str) -> Result<Self, DrizzleError>
       where Self: Sized;
}
Expand description

Object-safe view of a Rust enum stored as a PostgreSQL enum value.

#[derive(PostgresEnum)] implements it for enums stored as a native PostgreSQL enum type; integer-backed (#[repr(...)]) enums do not get it. It lets a PostgresValue hold any enum value as dyn PostgresEnum and bind it with its type name.

Required Methods§

Source

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

Returns the PostgreSQL enum type name, such as "mood".

Source

fn as_enum(&self) -> &dyn PostgresEnum

Returns self as a trait object.

Source

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

Returns the variant’s SQL label, such as "happy".

Source

fn into_boxed(&self) -> Box<dyn PostgresEnum>

Clones this value into a boxed trait object.

Source

fn try_from_str(value: &str) -> Result<Self, DrizzleError>
where Self: Sized,

Parses a variant from its SQL label.

§Errors

Returns DrizzleError::ConversionError when value is not a valid variant name for this enum.

Trait Implementations§

Source§

impl Clone for Box<dyn PostgresEnum>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for &dyn PostgresEnum

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Debug for Box<dyn PostgresEnum>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for &dyn PostgresEnum

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq for Box<dyn PostgresEnum>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§