pub enum VariantFormat {
Unit,
NewtypeScalar {
inner_shape: &'static Shape,
},
NewtypeStruct {
inner_shape: &'static Shape,
},
NewtypeTuple {
inner_shape: &'static Shape,
arity: usize,
},
NewtypeOther {
inner_shape: &'static Shape,
},
Tuple {
arity: usize,
},
Struct,
}Expand description
Classification of an enum variant’s expected serialized format.
This is used by deserializers to determine how to parse untagged enum variants based on the YAML/JSON/etc. value type they encounter.
Variants§
Unit
Unit variant: no fields, serializes as the variant name or nothing for untagged
NewtypeScalar
Newtype variant wrapping a scalar type (String, numbers, bool, etc.) Serializes as just the scalar value for untagged enums.
NewtypeStruct
Newtype variant wrapping a struct Serializes as a mapping for untagged enums.
NewtypeTuple
Newtype variant wrapping a tuple struct/tuple Serializes as a sequence for untagged enums.
Fields
NewtypeOther
Newtype variant wrapping another type (enum, sequence, etc.)
Tuple
Tuple variant with multiple fields Serializes as a sequence for untagged enums.
Struct
Struct variant with named fields Serializes as a mapping for untagged enums.
Implementations§
Source§impl VariantFormat
impl VariantFormat
Sourcepub fn from_variant(variant: &'static Variant) -> Self
pub fn from_variant(variant: &'static Variant) -> Self
Classify a variant’s expected serialized format.
Sourcepub fn expects_scalar(&self) -> bool
pub fn expects_scalar(&self) -> bool
Returns true if this variant expects a scalar value in untagged format.
Sourcepub fn expects_sequence(&self) -> bool
pub fn expects_sequence(&self) -> bool
Returns true if this variant expects a sequence in untagged format.
Sourcepub fn expects_mapping(&self) -> bool
pub fn expects_mapping(&self) -> bool
Returns true if this variant expects a mapping in untagged format.
Trait Implementations§
Source§impl Clone for VariantFormat
impl Clone for VariantFormat
Source§fn clone(&self) -> VariantFormat
fn clone(&self) -> VariantFormat
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more