Trait serde::de::VariantVisitor
[−]
[src]
pub trait VariantVisitor { type Error: Error; fn visit_unit(self) -> Result<(), Self::Error>; fn visit_newtype<T>(self) -> Result<T, Self::Error> where T: Deserialize; fn visit_tuple<V>(self,
len: usize,
visitor: V)
-> Result<V::Value, Self::Error> where V: Visitor; fn visit_struct<V>(self,
fields: &'static [&'static str],
visitor: V)
-> Result<V::Value, Self::Error> where V: Visitor; }
VariantVisitor
is a visitor that is created by the Deserializer
and
passed to the Deserialize
to deserialize the content of a particular enum
variant.
Associated Types
Required Methods
fn visit_unit(self) -> Result<(), Self::Error>
visit_unit
is called when deserializing a variant with no values.
fn visit_newtype<T>(self) -> Result<T, Self::Error> where T: Deserialize
visit_newtype
is called when deserializing a variant with a single value.
A good default is often to use the visit_tuple
method to deserialize a (value,)
.
fn visit_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor
visit_tuple
is called when deserializing a tuple-like variant.
If no tuple variants are expected, yield a
Err(serde::de::Error::invalid_type(serde::de::Type::TupleVariant))
fn visit_struct<V>(self,
fields: &'static [&'static str],
visitor: V)
-> Result<V::Value, Self::Error> where V: Visitor
fields: &'static [&'static str],
visitor: V)
-> Result<V::Value, Self::Error> where V: Visitor
visit_struct
is called when deserializing a struct-like variant.
If no struct variants are expected, yield a
Err(serde::de::Error::invalid_type(serde::de::Type::StructVariant))