Trait EnumAccess
trait EnumAccess<'de>: Sized
Provides a Visitor access to the data of an enum in the input.
EnumAccess is created by the Deserializer and passed to the
Visitor in order to identify which variant of an enum to deserialize.
Lifetime
The 'de lifetime of this trait is the lifetime of data that may be
borrowed by the deserialized enum variant. See the page Understanding
deserializer lifetimes for a more detailed explanation of these lifetimes.
Example implementation
The example data format presented on the website demonstrates an
implementation of EnumAccess for a basic JSON data format.
Associated Types
type Error: TraitBound { trait_: Path { path: "Error", id: Id(217), args: None }, generic_params: [], modifier: None }The error type that can be returned if some error occurs during deserialization.
type Variant: TraitBound { trait_: Path { path: "VariantAccess", id: Id(2556), args: Some(AngleBracketed { args: [Lifetime("'de")], constraints: [AssocItemConstraint { name: "Error", args: None, binding: Equality(Type(QualifiedPath { name: "Error", args: None, self_type: Generic("Self"), trait_: Some(Path { path: "", id: Id(1289), args: None }) })) }] }) }, generic_params: [], modifier: None }The
Visitorthat will be used to deserialize the content of the enum variant.
Required Methods
fn variant_seed<V>(self: Self, seed: V) -> Result<(<V as >::Value, <Self as >::Variant), <Self as >::Error> where V: DeserializeSeed<'de>variantis called to identify which variant to deserialize.Deserializeimplementations should typically useEnumAccess::variantinstead.
Provided Methods
fn variant<V>(self: Self) -> Result<(V, <Self as >::Variant), <Self as >::Error> where V: Deserialize<'de>variantis called to identify which variant to deserialize.This method exists as a convenience for
Deserializeimplementations.EnumAccessimplementations should not override the default behavior.
Implementors
impl<'de, E> EnumAccess for BorrowedStrDeserializer<'de, E>impl<'de, 'a, E> EnumAccess for CowStrDeserializer<'a, E>impl<'de, 'a, E> EnumAccess for StrDeserializer<'a, E>impl<'de, E> EnumAccess for U32Deserializer<E>impl<'de, E> EnumAccess for StringDeserializer<E>impl<'de, A> EnumAccess for MapAccessDeserializer<A>