FrameDecoder

Trait FrameDecoder 

Source
pub trait FrameDecoder {
    type Frame;

    // Required method
    fn decode(&mut self, buf: &[u8]) -> Result<DecodeResult<Self::Frame>>;
}
Expand description

A trait for non-allocating, pull-based frame decoders.

Implement this trait for any wire format requiring message boundary detection, such as Arrow IPC, protobuf, or custom binary protocols.

The decoder should never allocate or retain buffer data. It must only inspect the provided slice and return either a complete frame and how many bytes were consumed, or indicate that more data is needed.

§Safety Contract

  • The decoder musn’t mutate or take ownership of the input buffer.
  • It must not remove bytes itself—return consumed, the caller will drop them.
  • It should always leave the buffer unchanged if returning NeedMore.

Required Associated Types§

Source

type Frame

The type of frame yielded by this decoder.

Required Methods§

Source

fn decode(&mut self, buf: &[u8]) -> Result<DecodeResult<Self::Frame>>

Attempt to decode a complete frame from the start of buf.

Return:

  • Ok(Frame { frame, consumed }) if a full frame is present. Caller removes consumed bytes.
  • Ok(NeedMore) if more bytes are required; buffer remains unchanged.
  • Err if the protocol is violated, or an unrecoverable error is detected.

Implementors§