pub trait VariantAccess<'de>: Sized {
type Error: Error;
// Required method
fn unit_variant(self) -> Result<(), Self::Error>;
}
Expand description
VariantAccess
is a visitor that is created by the Deserializer
and
passed to the Deserialize
to deserialize the content of a particular enum
variant.
§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 VariantAccess
for a basic JSON data format.
Required Associated Types§
Required Methods§
Sourcefn unit_variant(self) -> Result<(), Self::Error>
fn unit_variant(self) -> Result<(), Self::Error>
Called when deserializing a variant with no values.
Check that the value of the enum is of a valid type immediately after deserialization with EnumAccess::variant
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.