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§
Sourcefn enum_type_name(&self) -> &'static str
fn enum_type_name(&self) -> &'static str
Returns the PostgreSQL enum type name, such as "mood".
Sourcefn as_enum(&self) -> &dyn PostgresEnum
fn as_enum(&self) -> &dyn PostgresEnum
Returns self as a trait object.
Sourcefn variant_name(&self) -> &'static str
fn variant_name(&self) -> &'static str
Returns the variant’s SQL label, such as "happy".
Sourcefn into_boxed(&self) -> Box<dyn PostgresEnum>
fn into_boxed(&self) -> Box<dyn PostgresEnum>
Clones this value into a boxed trait object.
Sourcefn try_from_str(value: &str) -> Result<Self, DrizzleError>where
Self: Sized,
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>
impl Clone for Box<dyn PostgresEnum>
Source§impl Debug for &dyn PostgresEnum
impl Debug for &dyn PostgresEnum
Source§impl Debug for Box<dyn PostgresEnum>
impl Debug for Box<dyn PostgresEnum>
Source§impl PartialEq for &dyn PostgresEnum
impl PartialEq for &dyn PostgresEnum
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".