Skip to main content

Module binary_frame

Module binary_frame 

Source
Expand description

The binary wire frame: [u32 BE header length][JSON header][raw payload bytes], all in ONE WebSocket binary message.

Bulk payloads (laboratory-transfer chunks) never ride base64 inside JSON — the typed envelope a text frame would carry serializes UNCHANGED as the header (its data field is #[serde(skip)]), and the raw bytes follow out of band. Correlation is exactly the text frame’s: the header holds the same ids. A receiver reads the length, parses the header with the same serde types it already uses, and attaches the remaining bytes to the chunk field.

Std-only and transport-agnostic — both WebSocket hops (daemon ↔ laboratory host, API ↔ daemon reverse channel) share it.

Enums§

WireFrame
One decoded-or-encoded wire frame: JSON text for every ordinary message, the binary sandwich for chunk-bearing ones.

Functions§

decode
Split a binary sandwich back into (header JSON, payload bytes). None on anything malformed — a short frame, a header length past the end, or a non-UTF-8 header. Malformed frames are DROPPED by receivers (forward-compat posture, mirroring unknown text frames).
encode
Build the binary sandwich. header is the frame’s full JSON envelope (minus the payload bytes, which its serde representation skips); payload may be empty (chunk variants are ALWAYS binary, content notwithstanding — the framing is variant-keyed, never content-sniffed).