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