use crate::Context;
use super::{Encode, Encoder};
pub trait EntriesEncoder {
type Cx: ?Sized + Context;
type Ok;
type EncodeEntryKey<'this>: Encoder<
Cx = Self::Cx,
Ok = Self::Ok,
Error = <Self::Cx as Context>::Error,
Mode = <Self::Cx as Context>::Mode,
>
where
Self: 'this;
type EncodeEntryValue<'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_entry_key(
&mut self,
) -> Result<Self::EncodeEntryKey<'_>, <Self::Cx as Context>::Error>;
#[must_use = "Encoders must be consumed"]
fn encode_entry_value(
&mut self,
) -> Result<Self::EncodeEntryValue<'_>, <Self::Cx as Context>::Error>;
fn finish_entries(self) -> Result<Self::Ok, <Self::Cx as Context>::Error>;
#[inline]
fn insert_entry<K, V>(&mut self, key: K, value: V) -> Result<(), <Self::Cx as Context>::Error>
where
K: Encode<<Self::Cx as Context>::Mode>,
V: Encode<<Self::Cx as Context>::Mode>,
{
self.encode_entry_key()?.encode(key)?;
self.encode_entry_value()?.encode(value)?;
Ok(())
}
}