Expand description
Transport framing over SimpleX direct connections (specification §5).
An envelope’s compact JSON text travels as one whole frame message (zaun:1:<json>) or,
when it does not fit the per-message budget, as 2–32 fragment messages
(zaun:1f:<frag_id>:<index>:<count>:<chunk>). encode produces the messages,
classify recognises an inbound text, and a Reassembler per connection joins
fragments under the bounds of §5.2. Every message emitted costs one SMP message against
the in-flight window (§10.5), so EncodedFrame::smp_messages is what flow control counts.
Pure: no I/O, no clock (time is now_ms), no randomness (the caller supplies FragId).
Modules§
- app_
data - How one frame message travels as SimpleX application data (specification §5.1): content type
DATA_TAG, the frame text underFRAME_KEY, and the fixedFALLBACK_TEXTan app without Zaun shows.
Structs§
- Encoded
Frame - The transport messages of one frame, in sending order.
- FragId
- A fragment id: 8 random bytes, unique per sender per connection among open reassemblies.
- Fragment
- One fragment message (§5.1), borrowing its chunk from the received text.
- Reassembler
- Per-connection reassembly state machine (§5.2).
Enums§
- Discard
Reason - Why a reassembly (or a fragment that would start one) was discarded. A discard produces no response; the sender’s retry repairs it (§5.2, §7.3).
- Encode
Error - Why an envelope cannot be framed.
- Inbound
- What an inbound transport text is (§5.3).
- Pushed
- The result of pushing one fragment.
Constants§
- FRAGMENT_
PREFIX - Prefix of a fragment message.
- FRAG_
ID_ CHARS - Length of an encoded
FragId(8 bytes, base64url without padding). - MIN_
BUDGET - The smallest accepted per-message budget: a fragment header plus one character at its
largest escaped (six bytes,
escaped_len). - PROTOCOL_
PREFIX - Prefix shared by every protocol message; text without it is not a protocol message (§5.3).
- WHOLE_
PREFIX - Prefix of a whole-envelope message.
Functions§
- classify
- Classifies one inbound text message. The
zaun:1f:prefix is tested beforezaun:1:(they differ at the 7th byte, so the order is only for clarity). - encode
- Frames the compact envelope JSON
json(§5.1). - escaped_
len - The bytes
texttakes written inside a JSON string, as a frame message travels in its application data (§5.1):"and\take two, the control characters JSON writes as\b,\t,\n,\f,\rtwo, every other control character six (\u00XX).