Skip to main content

Module stream

Module stream 

Source
Expand description

Streaming framing / deframing — process a byte STREAM of length-delimited messages INCREMENTALLY, as bytes arrive, without ever buffering the whole stream. This is the basis of every streaming protocol (gRPC, Arrow Flight, Kafka): a producer frames each message as [uvarint length][body]; a consumer feeds arriving chunks — ANY chunking, from byte-at-a-time to many frames at once to a frame split across chunks — to a StreamDeframer, which hands back each complete frame the instant it is buffered, ZERO-COPY (the body is a borrowed slice, so pair it with crate::concurrency::marshal::view_message for a fully in-place stream read).

Paired with the zero-copy WireView receive, this closes Cap’n Proto’s streaming claim: incremental reads with no whole-stream buffering and no decode of untouched fields.

Structs§

StreamDeframer
An incremental deframer. Feed it arriving bytes with push; pull complete frames with drain_frames. Holds only the bytes not yet delivered (a partial frame at most), so memory stays bounded regardless of stream length.

Functions§

frame_for_stream
Frame body for the stream: a LEB128 length prefix, then the bytes. Append-only into out, so a producer can concatenate many frames into one stream buffer.