Expand description
Frames of the host protocol: an 8-byte preamble, a JSON header and binary attachments.
The preamble holds the header’s length and the attachments’ total length, both little-endian
u32, so a reader finds the next frame without parsing the header. The header’s attachments
lists each attachment’s type and bytes, in order.
Structs§
- Attachment
- One attachment of a frame.
- Frame
- A frame as read: its header and its attachments’ bytes, not yet split.
- Frame
Limits - The largest frame a reader takes; a larger one is read through and dropped.
Enums§
- Read
Frame - What
read_framefound.
Constants§
- MAGIC
- What
servewrites before its first frame, so a reader skips whatever reached the stream before the host owned it. - MAX_
ATTACHMENT_ TYPE_ BYTES - The most an attachment’s
typemay hold.
Functions§
- frame_
bytes - One frame’s bytes, preamble included, so it is written in one piece.
- read_
frame - Reads the next frame.
- skip_
to_ magic - Reads up to and through
MAGICand returns what came before it;Nonewhen the stream ended orlimitbytes passed first. - split_
attachments - Splits
bytesas the header’sattachmentslist says. - write_
frame - Writes one frame and flushes it.