[−][src]Trait serde::de::EnumAccess
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: Error
The error type that can be returned if some error occurs during deserialization.
type Variant: VariantAccess<'de, Error = Self::Error>
The Visitor
that will be used to deserialize the content of the enum
variant.
Required methods
fn variant_seed<V>(
self,
seed: V
) -> Result<(V::Value, Self::Variant), Self::Error> where
V: DeserializeSeed<'de>,
self,
seed: V
) -> Result<(V::Value, Self::Variant), Self::Error> where
V: DeserializeSeed<'de>,
variant
is called to identify which variant to deserialize.
Deserialize
implementations should typically use EnumAccess::variant
instead.
Provided methods
fn variant<V>(self) -> Result<(V, Self::Variant), Self::Error> where
V: Deserialize<'de>,
V: Deserialize<'de>,
variant
is called to identify which variant to deserialize.
This method exists as a convenience for Deserialize
implementations.
EnumAccess
implementations should not override the default behavior.
Implementors
impl<'de, 'a, E> EnumAccess<'de> for CowStrDeserializer<'a, E> where
E: Error,
[src]
E: Error,
type Error = E
type Variant = UnitOnly<E>
fn variant_seed<T>(
self,
seed: T
) -> Result<(T::Value, Self::Variant), Self::Error> where
T: DeserializeSeed<'de>,
[src]
self,
seed: T
) -> Result<(T::Value, Self::Variant), Self::Error> where
T: DeserializeSeed<'de>,
fn variant<V>(self) -> Result<(V, Self::Variant), Self::Error> where
V: Deserialize<'de>,
[src]
V: Deserialize<'de>,
impl<'de, 'a, E> EnumAccess<'de> for StrDeserializer<'a, E> where
E: Error,
[src]
E: Error,
type Error = E
type Variant = UnitOnly<E>
fn variant_seed<T>(
self,
seed: T
) -> Result<(T::Value, Self::Variant), Self::Error> where
T: DeserializeSeed<'de>,
[src]
self,
seed: T
) -> Result<(T::Value, Self::Variant), Self::Error> where
T: DeserializeSeed<'de>,
fn variant<V>(self) -> Result<(V, Self::Variant), Self::Error> where
V: Deserialize<'de>,
[src]
V: Deserialize<'de>,
impl<'de, 'a, E> EnumAccess<'de> for StringDeserializer<E> where
E: Error,
[src]
E: Error,
type Error = E
type Variant = UnitOnly<E>
fn variant_seed<T>(
self,
seed: T
) -> Result<(T::Value, Self::Variant), Self::Error> where
T: DeserializeSeed<'de>,
[src]
self,
seed: T
) -> Result<(T::Value, Self::Variant), Self::Error> where
T: DeserializeSeed<'de>,
fn variant<V>(self) -> Result<(V, Self::Variant), Self::Error> where
V: Deserialize<'de>,
[src]
V: Deserialize<'de>,
impl<'de, A> EnumAccess<'de> for MapAccessDeserializer<A> where
A: MapAccess<'de>,
[src]
A: MapAccess<'de>,
type Error = A::Error
type Variant = MapAsEnum<A>
fn variant_seed<T>(
self,
seed: T
) -> Result<(T::Value, Self::Variant), Self::Error> where
T: DeserializeSeed<'de>,
[src]
self,
seed: T
) -> Result<(T::Value, Self::Variant), Self::Error> where
T: DeserializeSeed<'de>,
fn variant<V>(self) -> Result<(V, Self::Variant), Self::Error> where
V: Deserialize<'de>,
[src]
V: Deserialize<'de>,
impl<'de, E> EnumAccess<'de> for BorrowedStrDeserializer<'de, E> where
E: Error,
[src]
E: Error,
type Error = E
type Variant = UnitOnly<E>
fn variant_seed<T>(
self,
seed: T
) -> Result<(T::Value, Self::Variant), Self::Error> where
T: DeserializeSeed<'de>,
[src]
self,
seed: T
) -> Result<(T::Value, Self::Variant), Self::Error> where
T: DeserializeSeed<'de>,
fn variant<V>(self) -> Result<(V, Self::Variant), Self::Error> where
V: Deserialize<'de>,
[src]
V: Deserialize<'de>,
impl<'de, E> EnumAccess<'de> for U32Deserializer<E> where
E: Error,
[src]
E: Error,