musli_core/en/
map_encoder.rsuse crate::Context;
use super::{Encode, EntryEncoder};
pub trait MapEncoder {
type Cx: ?Sized + Context;
type Ok;
type EncodeEntry<'this>: EntryEncoder<Cx = Self::Cx, Ok = Self::Ok>
where
Self: 'this;
#[must_use = "Encoders must be consumed"]
fn encode_entry(&mut self) -> Result<Self::EncodeEntry<'_>, <Self::Cx as Context>::Error>;
#[inline]
fn encode_entry_fn<F>(&mut self, f: F) -> Result<Self::Ok, <Self::Cx as Context>::Error>
where
F: FnOnce(&mut Self::EncodeEntry<'_>) -> Result<(), <Self::Cx as Context>::Error>,
{
let mut encoder = self.encode_entry()?;
f(&mut encoder)?;
encoder.finish_entry()
}
#[inline]
fn insert_entry<F, S>(&mut self, key: F, value: S) -> Result<(), <Self::Cx as Context>::Error>
where
Self: Sized,
F: Encode<<Self::Cx as Context>::Mode>,
S: Encode<<Self::Cx as Context>::Mode>,
{
self.encode_entry()?.insert_entry(key, value)?;
Ok(())
}
fn finish_map(self) -> Result<Self::Ok, <Self::Cx as Context>::Error>;
}