mod counter;
#[cfg(feature = "io")]
mod io;
mod len;
mod slice;
mod vec;
pub use counter::CounterPacker;
#[cfg(feature = "io")]
pub use io::IoPacker;
pub(crate) use len::LenPacker;
pub use slice::SlicePacker;
pub trait Packer {
type Error;
fn pack_bytes<B: AsRef<[u8]>>(&mut self, bytes: B) -> Result<(), Self::Error>;
#[inline]
fn written_bytes(&self) -> Option<usize> {
None
}
}
impl<P: Packer + ?Sized> Packer for &mut P {
type Error = P::Error;
#[inline]
fn pack_bytes<B: AsRef<[u8]>>(&mut self, bytes: B) -> Result<(), Self::Error> {
P::pack_bytes(*self, bytes)
}
#[inline]
fn written_bytes(&self) -> Option<usize> {
P::written_bytes(*self)
}
}