Skip to main content

decode_snapshot_chunk

Function decode_snapshot_chunk 

Source
pub fn decode_snapshot_chunk(buf: &[u8]) -> Result<(&[u8], usize), WireError>
Expand description

Decode the next snapshot chunk ($L\r\n<L bytes>\r\n) at the front of buf. Returns:

  • Ok((chunk_bytes, used))chunk_bytes borrows from buf; used bytes were consumed.
  • Err(WireError::Truncated) — not enough bytes for a complete chunk yet.
  • Err(WireError::BadEnvelope) — header wasn’t $L\r\n, L exceeded SNAPSHOT_CHUNK_MAX, L parsed as non-numeric, or the trailing CRLF was missing.