Trait bee_common::packable::Packable [−][src]
pub trait Packable {
type Error: Debug;
fn packed_len(&self) -> usize;
fn pack<W: Write>(&self, writer: &mut W) -> Result<(), Self::Error>;
fn unpack_inner<R: Read + ?Sized, const CHECK: bool>(
reader: &mut R
) -> Result<Self, Self::Error>
where
Self: Sized;
fn pack_new(&self) -> Vec<u8>ⓘ { ... }
fn unpack<R: Read + ?Sized>(reader: &mut R) -> Result<Self, Self::Error>
where
Self: Sized,
{ ... }
fn unpack_unchecked<R: Read + ?Sized>(
reader: &mut R
) -> Result<Self, Self::Error>
where
Self: Sized,
{ ... }
}
Expand description
A trait to pack and unpack types to and from bytes.
Associated Types
Required methods
fn packed_len(&self) -> usize
fn packed_len(&self) -> usize
Returns the length of the packed bytes.
Packs the instance to bytes and writes them to the passed writer.
Provided methods
Packs the instance to bytes and writes them to a newly allocated vector.
Reads bytes from the passed reader and unpacks them into an instance. Applies syntactic checks.