pub enum EnumValues {
String(Vec<String>),
Integer(Vec<NumValue>),
}Expand description
The set of allowed values for an enum column, either string-based or integer-based.
String enums map to a native PostgreSQL ENUM type. Adding or removing values requires a
database migration (ALTER TYPE).
Integer enums are stored as INTEGER. New variants can be added to the model without any
database migration because the underlying column type never changes.
Choose integer enums for expandable value sets (roles, priorities) and string enums for stable, human-readable status fields.
Variants§
String(Vec<String>)
String enum: each variant is a plain string stored in a native DB enum type.
Integer(Vec<NumValue>)
Integer enum: each variant has an explicit numeric value stored as INTEGER.
Implementations§
Source§impl EnumValues
impl EnumValues
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Check if this is an integer enum
Sourcepub fn variant_names(&self) -> Vec<&str>
pub fn variant_names(&self) -> Vec<&str>
Get all variant names
Sourcepub fn to_sql_values(&self) -> Vec<String>
pub fn to_sql_values(&self) -> Vec<String>
Get SQL values for CREATE TYPE ENUM (only for string enums) Returns quoted strings like ‘value1’, ‘value2’
Trait Implementations§
Source§impl Clone for EnumValues
impl Clone for EnumValues
Source§fn clone(&self) -> EnumValues
fn clone(&self) -> EnumValues
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EnumValues
impl Debug for EnumValues
Source§impl<'de> Deserialize<'de> for EnumValues
impl<'de> Deserialize<'de> for EnumValues
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for EnumValues
Source§impl JsonSchema for EnumValues
impl JsonSchema for EnumValues
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for EnumValues
impl PartialEq for EnumValues
Source§fn eq(&self, other: &EnumValues) -> bool
fn eq(&self, other: &EnumValues) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for EnumValues
impl Serialize for EnumValues
impl StructuralPartialEq for EnumValues
Auto Trait Implementations§
impl Freeze for EnumValues
impl RefUnwindSafe for EnumValues
impl Send for EnumValues
impl Sync for EnumValues
impl Unpin for EnumValues
impl UnsafeUnpin for EnumValues
impl UnwindSafe for EnumValues
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more