1use crate::Context;
23use super::{Decoder, SizeHint};
45/// Trait governing how to decode a map entry.
6pub trait EntryDecoder<'de> {
7/// Context associated with the decoder.
8type Cx: ?Sized + Context;
9/// The decoder to use for a tuple field index.
10type DecodeKey<'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 a tuple field value.
19type DecodeValue: Decoder<
20'de,
21 Cx = Self::Cx,
22 Error = <Self::Cx as Context>::Error,
23 Mode = <Self::Cx as Context>::Mode,
24 >;
2526/// Get a size hint for the size of the map being decoded.
27#[inline]
28fn size_hint(&self) -> SizeHint {
29 SizeHint::any()
30 }
3132/// Return the decoder for the first value in the pair.
33 ///
34 /// If this is a map the first value would be the key of the map, if this is
35 /// a struct the first value would be the field of the struct.
36#[must_use = "Decoders must be consumed"]
37fn decode_key(&mut self) -> Result<Self::DecodeKey<'_>, <Self::Cx as Context>::Error>;
3839/// Decode the second value in the pair..
40#[must_use = "Decoders must be consumed"]
41fn decode_value(self) -> Result<Self::DecodeValue, <Self::Cx as Context>::Error>;
42}