1use crate::Context;
23use super::Decoder;
45/// Trait governing how to decode a variant.
6pub trait VariantDecoder<'de> {
7/// Context associated with the decoder.
8type Cx: ?Sized + Context;
9/// The decoder to use for the variant tag.
10type DecodeTag<'this>: Decoder<
11'de,
12 Cx = Self::Cx,
13 Error = <Self::Cx as Context>::Error,
14 Mode = <Self::Cx as Context>::Mode,
15 >
16where
17Self: 'this;
18/// The decoder to use for the variant value.
19type DecodeValue<'this>: Decoder<
20'de,
21 Cx = Self::Cx,
22 Error = <Self::Cx as Context>::Error,
23 Mode = <Self::Cx as Context>::Mode,
24 >
25where
26Self: 'this;
2728/// Return the decoder for the first value in the pair.
29 ///
30 /// If this is a map the first value would be the key of the map, if this is
31 /// a struct the first value would be the field of the struct.
32#[must_use = "Decoders must be consumed"]
33fn decode_tag(&mut self) -> Result<Self::DecodeTag<'_>, <Self::Cx as Context>::Error>;
3435/// Decode the second value in the pair..
36#[must_use = "Decoders must be consumed"]
37fn decode_value(&mut self) -> Result<Self::DecodeValue<'_>, <Self::Cx as Context>::Error>;
38}