Skip to main content

Framer

Trait Framer 

Source
pub trait Framer<B>
where B: IoBufMut,
{ // Required methods fn enclose(&mut self, buf: &mut B); fn extract(&mut self, buf: &Slice<B>) -> Result<Option<Frame>, Error>; }
Available on crate feature io only.
Expand description

Enclosing and extracting frames in a buffer.

Required Methods§

Source

fn enclose(&mut self, buf: &mut B)

Enclose a frame in the given buffer.

All initialized bytes in buf (buf[0..buf.buf_len()]) are valid and required to be enclosed. All modifications should happen in-place; one can use IoBufMut::reserve, IoBufMut::copy_within or a temporary buffer if prepending data is necessary.

Source

fn extract(&mut self, buf: &Slice<B>) -> Result<Option<Frame>, Error>

Extract a frame from the given buffer.

§Returns
  • Ok(Some(frame)) if a complete frame is found.
  • Ok(None) if no complete frame is found.
  • Err(io::Error) if an error occurs during extraction.

Implementors§

Source§

impl<B> Framer<B> for AnyDelimited<'_>
where B: IoBufMut,

Source§

impl<B> Framer<B> for LengthDelimited
where B: IoBufMut,

Source§

impl<B> Framer<B> for NoopFramer
where B: IoBufMut,

Source§

impl<B, const C: char> Framer<B> for CharDelimited<C>
where B: IoBufMut,