pub struct EmbeddedEnum {
pub id: ModelId,
pub name: Name,
pub discriminant: FieldPrimitive,
pub variants: Vec<EnumVariant>,
pub fields: Vec<Field>,
pub indices: Vec<Index>,
}Expand description
An embedded enum model stored in the parent table via a discriminant column and optional per-variant data columns.
The discriminant column holds a value (integer or string) identifying the active variant. Variants may optionally carry data fields, which are stored as additional nullable columns in the parent table.
§Examples
let ee = model.as_embedded_enum_unwrap();
for variant in &ee.variants {
println!("variant {} = {}", variant.name.upper_camel_case(), variant.discriminant);
}Fields§
§id: ModelIdUniquely identifies this model within the schema.
name: NameThe model’s name.
discriminant: FieldPrimitiveThe primitive type used for the discriminant column.
variants: Vec<EnumVariant>The enum’s variants.
fields: Vec<Field>All fields across all variants, with global indices. Each field’s
variant identifies which variant it belongs to.
indices: Vec<Index>Indices defined on this embedded enum’s variant fields.
These reference fields within this embedded enum (not the parent model). The schema builder propagates them to physical DB indices on the parent table’s flattened columns.
Implementations§
Source§impl EmbeddedEnum
impl EmbeddedEnum
Sourcepub fn has_data_variants(&self) -> bool
pub fn has_data_variants(&self) -> bool
Returns true if at least one variant carries data fields.
Sourcepub fn variant_fields(
&self,
variant_index: usize,
) -> impl Iterator<Item = &Field>
pub fn variant_fields( &self, variant_index: usize, ) -> impl Iterator<Item = &Field>
Returns fields belonging to a specific variant.
Trait Implementations§
Source§impl Clone for EmbeddedEnum
impl Clone for EmbeddedEnum
Source§fn clone(&self) -> EmbeddedEnum
fn clone(&self) -> EmbeddedEnum
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more