parse_frame

Function parse_frame 

Source
pub fn parse_frame(buf: &[u8]) -> Result<Option<Frame<'_>>, FramingError>
Expand description

Try to parse a single frame from the front of buf.

  • Ok(Some(frame)) — a complete frame is present; consume frame.total_len() bytes and call again for the next one.
  • Ok(None) — the buffer holds only a partial frame; append more bytes and retry. This is how incremental parsing over arbitrarily split TCP chunks works: the same partial buffer is re-offered once it has grown.
  • Err(_) — a hard protocol violation; the connection must be dropped.