musli_core/en/
entry_encoder.rsuse crate::Context;
use super::{Encode, Encoder};
pub trait EntryEncoder {
type Cx: ?Sized + Context;
type Ok;
type EncodeKey<'this>: Encoder<
Cx = Self::Cx,
Ok = Self::Ok,
Error = <Self::Cx as Context>::Error,
Mode = <Self::Cx as Context>::Mode,
>
where
Self: 'this;
type EncodeValue<'this>: Encoder<
Cx = Self::Cx,
Ok = Self::Ok,
Error = <Self::Cx as Context>::Error,
Mode = <Self::Cx as Context>::Mode,
>
where
Self: 'this;
#[must_use = "Encoders must be consumed"]
fn encode_key(&mut self) -> Result<Self::EncodeKey<'_>, <Self::Cx as Context>::Error>;
#[must_use = "Encoders must be consumed"]
fn encode_value(&mut self) -> Result<Self::EncodeValue<'_>, <Self::Cx as Context>::Error>;
fn finish_entry(self) -> Result<Self::Ok, <Self::Cx as Context>::Error>;
#[inline]
fn insert_entry<K, V>(
mut self,
key: K,
value: V,
) -> Result<Self::Ok, <Self::Cx as Context>::Error>
where
Self: Sized,
K: Encode<<Self::Cx as Context>::Mode>,
V: Encode<<Self::Cx as Context>::Mode>,
{
self.encode_key()?.encode(key)?;
self.encode_value()?.encode(value)?;
self.finish_entry()
}
}