Skip to main content

Module host_frames

Module host_frames 

Source
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.
FrameLimits
The largest frame a reader takes; a larger one is read through and dropped.

Enums§

ReadFrame
What read_frame found.

Constants§

MAGIC
What serve writes 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 type may 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 MAGIC and returns what came before it; None when the stream ended or limit bytes passed first.
split_attachments
Splits bytes as the header’s attachments list says.
write_frame
Writes one frame and flushes it.