pub struct VariantsByFormat {
pub scalar_variants: Vec<(&'static Variant, &'static Shape)>,
pub tuple_variants: Vec<(&'static Variant, usize)>,
pub struct_variants: Vec<&'static Variant>,
pub unit_variants: Vec<&'static Variant>,
pub other_variants: Vec<&'static Variant>,
}Expand description
Information about variants grouped by their expected format.
Used by deserializers to efficiently dispatch untagged enum parsing based on the type of value encountered.
Fields§
§scalar_variants: Vec<(&'static Variant, &'static Shape)>Variants that expect a scalar value (newtype wrapping String, i32, etc.)
tuple_variants: Vec<(&'static Variant, usize)>Variants that expect a sequence (tuple variants) Grouped by arity for efficient matching.
struct_variants: Vec<&'static Variant>Variants that expect a mapping (struct variants, newtype wrapping struct)
unit_variants: Vec<&'static Variant>Unit variants (no data)
other_variants: Vec<&'static Variant>Other variants that don’t fit the above categories
Implementations§
Source§impl VariantsByFormat
impl VariantsByFormat
Sourcepub fn from_shape(shape: &'static Shape) -> Option<Self>
pub fn from_shape(shape: &'static Shape) -> Option<Self>
Build variant classification for an enum shape.
Returns None if the shape is not an enum.
Sourcepub fn tuple_variants_with_arity(&self, arity: usize) -> Vec<&'static Variant>
pub fn tuple_variants_with_arity(&self, arity: usize) -> Vec<&'static Variant>
Get tuple variants with a specific arity.
Sourcepub fn has_scalar_variants(&self) -> bool
pub fn has_scalar_variants(&self) -> bool
Check if there are any scalar-expecting variants.
Sourcepub fn has_tuple_variants(&self) -> bool
pub fn has_tuple_variants(&self) -> bool
Check if there are any tuple-expecting variants.
Sourcepub fn has_struct_variants(&self) -> bool
pub fn has_struct_variants(&self) -> bool
Check if there are any struct-expecting variants.
Trait Implementations§
Source§impl Debug for VariantsByFormat
impl Debug for VariantsByFormat
Source§impl Default for VariantsByFormat
impl Default for VariantsByFormat
Source§fn default() -> VariantsByFormat
fn default() -> VariantsByFormat
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for VariantsByFormat
impl RefUnwindSafe for VariantsByFormat
impl Send for VariantsByFormat
impl Sync for VariantsByFormat
impl Unpin for VariantsByFormat
impl UnwindSafe for VariantsByFormat
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
Mutably borrows from an owned value. Read more