Expand description
Messages over a byte stream — a socket, a pipe: each message a frame,
its length (a little-endian u32) and then its binary form. What
programs say to each other (a program and its editor, a tool’s service).
Structs§
- Frame
Reader - Reads frames into a buffer it keeps, so a stream of messages costs no
allocation per frame once the buffer has grown to the biggest. The end
rules are those of
super::read_frame_bytes: a clean end only between frames; a stream cut inside a length or a frame is an error. - Frame
Writer - Sends messages as frames without allocating per message: it keeps the
buffers a message is written into, so once they have grown to the
biggest message, a send only writes. Each frame (its length, then its
body) goes out in one
write_all, then the writer is flushed.
Constants§
- MAX_
FRAME - The longest frame read: anything longer is a broken or hostile peer.
Functions§
- read_
frame - The next message;
Nonewhere the stream ends between frames. - read_
frame_ bytes - The next frame’s bytes;
Nonewhere the stream ends between frames. - write_
frame - Writes
messageas one frame, and flushes. - write_
frame_ bytes - Writes
bytes(a message’s binary form) as one frame, and flushes.
Type Aliases§
- Len
- How a frame’s length is written.