pub struct VariantsByFormat {
pub scalar_variants: Vec<(&'static Variant, &'static Shape)>,
pub bool_variants: Vec<(&'static Variant, &'static Shape)>,
pub int_variants: Vec<(&'static Variant, &'static Shape)>,
pub float_variants: Vec<(&'static Variant, &'static Shape)>,
pub string_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.)
Deprecated: Use the type-specific fields below for better type matching. This field contains all scalar variants regardless of type.
bool_variants: Vec<(&'static Variant, &'static Shape)>Variants that expect a boolean value (newtype wrapping bool)
int_variants: Vec<(&'static Variant, &'static Shape)>Variants that expect an integer value (newtype wrapping i8, u8, i32, u64, etc.)
float_variants: Vec<(&'static Variant, &'static Shape)>Variants that expect a float value (newtype wrapping f32, f64)
string_variants: Vec<(&'static Variant, &'static Shape)>Variants that expect a string value (newtype wrapping String, &str, Cow<str>)
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.