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:
cobs_encode/cobs_decode— downstreamrzcobs_encode/rzcobs_decode— upstream
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:
- The upstream crate fails to build against a Rust edition / MSRV we need.
- A correctness or performance bug is identified and no upstream fix lands within 30 days.
- 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:
- COBS: Cheshire & Baker 1999; worst-case overhead
ceil(n / 254)bytes, surfaced viacobs::max_encoding_length. - rzCOBS: https://github.com/Dirbaio/rzcobs#algorithm (7-byte
chunks; bitmap control byte; literal runs); worst-case overhead
surfaced via
max_rzcobs_encoding_length.
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§
- Frame
Accumulator - Byte-by-byte frame accumulator for COBS-framed streams.
Constants§
- MAX_
FRAME_ SIZE - Maximum encoded/framed frame size including the
0x00frame delimiter.
Functions§
- cobs_
decode - COBS-decode
src(without the0x00delimiter) intodst. - cobs_
encode - COBS-encode
dataintodst, appending a0x00frame delimiter. - max_
rzcobs_ encoding_ length - Worst-case rzCOBS-encoded length for a payload of
nbytes, excluding the trailing0x00frame delimiter. - rzcobs_
decode - rzCOBS-decode
src(without the0x00delimiter) intodst. - rzcobs_
encode - rzCOBS-encode
dataintodst, appending a0x00frame delimiter.