VariantsByFormat

Struct VariantsByFormat 

Source
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

Source

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.

Source

pub fn tuple_variants_with_arity(&self, arity: usize) -> Vec<&'static Variant>

Get tuple variants with a specific arity.

Source

pub fn has_scalar_variants(&self) -> bool

Check if there are any scalar-expecting variants.

Source

pub fn has_tuple_variants(&self) -> bool

Check if there are any tuple-expecting variants.

Source

pub fn has_struct_variants(&self) -> bool

Check if there are any struct-expecting variants.

Trait Implementations§

Source§

impl Debug for VariantsByFormat

Source§

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

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

impl Default for VariantsByFormat

Source§

fn default() -> VariantsByFormat

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.