Struct buffertk::LengthPrefixer
source · pub struct LengthPrefixer<'a, P>where
P: Packable + 'a,{ /* private fields */ }Expand description
A type that packs a slice of objects by concatenating their packed representations. Prepends a length.
Trait Implementations§
source§impl<'a, P> Packable for LengthPrefixer<'a, P>where
P: Packable + 'a,
impl<'a, P> Packable for LengthPrefixer<'a, P>where P: Packable + 'a,
source§fn pack_sz(&self) -> usize
fn pack_sz(&self) -> usize
pack_sz returns the number of bytes required to serialize the Packable object.source§fn pack(&self, out: &mut [u8])
fn pack(&self, out: &mut [u8])
pack fills in the buffer out with the packed binary representation of the Packable
object. The implementor is responsible to ensure that out is exactly pack_sz() bytes
and implementations are encouraged to assert this. Read moresource§fn stream<W: Write>(&self, writer: &mut W) -> Result<usize, Error>where
Self: Sized,
for<'a> &'a Self: Packable,
fn stream<W: Write>(&self, writer: &mut W) -> Result<usize, Error>where Self: Sized, for<'a> &'a Self: Packable,
stream writes the object to the provided writer using the same representation that would
be used in a call to pack. The implementor is responsible for making sure that the
number of bytes written is exactly equal to the number of required bytes. Read more