Skip to main content

Module framing

Module framing 

Source
Expand description

Framing layer for the Telepath wire protocol.

Both directions terminate frames with a 0x00 byte. The encoding between frame bytes differs by direction:

  • Downstream (Host → Target): COBS
  • Upstream (Target → Host): rzCOBS

FrameAccumulator is framing-agnostic — it discovers boundaries by splitting on 0x00 and does not interpret the bytes between.

§Framing-crate replacement policy

Both COBS and rzCOBS are core wire infrastructure on the critical path for every packet. The current implementations are thin wrappers around the external cobs and rzcobs crates, but the stability contract is the wrapper API exposed by this module:

Both algorithm pairs are interchangeable with an in-tree implementation provided the wrapper signatures and crate::WireError mapping are preserved. Replacement may be triggered (symmetrically for either) by any of:

  1. The upstream crate fails to build against a Rust edition / MSRV we need.
  2. A correctness or performance bug is identified and no upstream fix lands within 30 days.
  3. Optimizations specific to Telepath are wanted (e.g. exploiting the known crate::MAX_PAYLOAD_SIZE = 256 bound, or fusing the encode pass with postcard serialization).

Reference materials for an in-tree rewrite:

Unit tests in mod tests cover embedded zeros, long literal runs, max-payload boundaries, and malformed input for both algorithms; any in-tree replacement MUST pass them unchanged.

Structs§

FrameAccumulator
Byte-by-byte frame accumulator for COBS-framed streams.

Constants§

MAX_FRAME_SIZE
Maximum encoded/framed frame size including the 0x00 frame delimiter.

Functions§

cobs_decode
COBS-decode src (without the 0x00 delimiter) into dst.
cobs_encode
COBS-encode data into dst, appending a 0x00 frame delimiter.
max_rzcobs_encoding_length
Worst-case rzCOBS-encoded length for a payload of n bytes, excluding the trailing 0x00 frame delimiter.
rzcobs_decode
rzCOBS-decode src (without the 0x00 delimiter) into dst.
rzcobs_encode
rzCOBS-encode data into dst, appending a 0x00 frame delimiter.