Skip to main content

Module framing

Module framing 

Source
Expand description

Incremental SSE and newline-delimited framing of response bytes. SSE dispatch requires a blank line; incomplete events are not flushed at EOF. NDJSON permits a final unterminated line through NdjsonFramer::finish. A framer holds at most its limit (FRAME_LIMIT unless given another) plus one byte of a frame: a larger frame is refused as TooLarge.

use rig_http::http_client::framing::NdjsonFramer;

let mut framer = NdjsonFramer::new();
assert_eq!(framer.push(b"{}\n").collect::<Vec<_>>(), vec![Ok(b"{}".to_vec())]);

Structs§

Framer
The incremental framer of one streamed reply, from Framing::framer.
NdjsonFramer
Splits nonempty newline-delimited payloads without validating JSON. A nonempty unterminated last line is available through Self::finish. A line counts its bytes before its line end, LF or CRLF.
RecordedSseEvent
A parsed event and the byte offset where it became dispatchable.
SseBatch
Parsed events and source lines consumed by a recording operation.
SseEvent
One dispatched text/event-stream event.
SseFramer
A push parser for the WHATWG text/event-stream grammar, which holds at most its limit plus one byte of an event (TooLarge).
SseLine
Original byte ranges of one line consumed by SseFramer.
TooLarge
A frame, line or input larger than its reader’s limit, refused before the reader’s buffer grew past it.

Enums§

Framing
How a reply’s bytes are split into wire frames.
SseField
A field recognized by the SSE grammar.
WireFrame
One transport frame, after framing but before decoding.

Constants§

FRAME_LIMIT
The most bytes one frame of a streamed reply may hold: an SSE event’s lines since the last blank line that a framer keeps (its data and any unfinished line), or an NDJSON line. Far above any real frame, and below what would exhaust memory.