Skip to main content

Module io

Module io 

Source
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§

FrameReader
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.
FrameWriter
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; None where the stream ends between frames.
read_frame_bytes
The next frame’s bytes; None where the stream ends between frames.
write_frame
Writes message as 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.