musli_core/de/
map_decoder.rsuse crate::Context;
use super::{Decode, Decoder, EntriesDecoder, EntryDecoder, SizeHint};
pub trait MapDecoder<'de> {
type Cx: ?Sized + Context;
type DecodeEntry<'this>: EntryDecoder<'de, Cx = Self::Cx>
where
Self: 'this;
type DecodeRemainingEntries<'this>: EntriesDecoder<'de, Cx = Self::Cx>
where
Self: 'this;
#[inline]
fn size_hint(&self) -> SizeHint {
SizeHint::any()
}
#[must_use = "Decoders must be consumed"]
fn decode_entry(
&mut self,
) -> Result<Option<Self::DecodeEntry<'_>>, <Self::Cx as Context>::Error>;
fn decode_remaining_entries(
&mut self,
) -> Result<Self::DecodeRemainingEntries<'_>, <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>,
{
let Some(mut entry) = self.decode_entry()? else {
return Ok(None);
};
let key = entry.decode_key()?.decode()?;
let value = entry.decode_value()?.decode()?;
Ok(Some((key, value)))
}
}