use crate::Context;
use super::{Decode, Decoder, MapEntriesDecoder, MapEntryDecoder, SizeHint};
pub trait MapDecoder<'de>: Sized {
type Cx: ?Sized + Context;
type DecodeEntry<'this>: MapEntryDecoder<'de, Cx = Self::Cx>
where
Self: 'this;
type DecodeRemainingEntries<'this>: MapEntriesDecoder<'de, Cx = Self::Cx>
where
Self: 'this;
fn size_hint(&self) -> SizeHint;
#[must_use = "Decoders must be consumed"]
fn decode_entry(
&mut self,
) -> Result<Option<Self::DecodeEntry<'_>>, <Self::Cx as Context>::Error>;
fn entry<K, V>(&mut self) -> Result<Option<(K, V)>, <Self::Cx as Context>::Error>
where
K: Decode<'de, <Self::Cx as Context>::Mode>,
V: Decode<'de, <Self::Cx as Context>::Mode>,
{
match self.decode_entry()? {
Some(mut entry) => {
let key = entry.decode_map_key()?.decode()?;
let value = entry.decode_map_value()?.decode()?;
Ok(Some((key, value)))
}
None => Ok(None),
}
}
fn decode_remaining_entries(
&mut self,
) -> Result<Self::DecodeRemainingEntries<'_>, <Self::Cx as Context>::Error>;
}