Framer

Trait Framer 

Source
pub trait Framer {
    // Required methods
    fn enclose(&mut self, buf: &mut Vec<u8>);
    fn extract(&mut self, buf: &[u8]) -> Option<Frame>;
}
Expand description

Enclosing and extracting frames in a buffer.

Required Methods§

Source

fn enclose(&mut self, buf: &mut Vec<u8>)

Enclose a frame in the given buffer.

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

Source

fn extract(&mut self, buf: &[u8]) -> Option<Frame>

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§