pub struct Framing;Expand description
Byte-stream framing flows: turn a stream of arbitrary Vec<u8> chunks into a stream of
complete logical frames. Mirrors Akka’s Framing/JsonFraming.
Implementations§
Source§impl Framing
impl Framing
Sourcepub fn delimiter(
delimiter: Vec<u8>,
maximum_frame_length: usize,
allow_truncation: bool,
) -> Flow<Vec<u8>, Vec<u8>>
pub fn delimiter( delimiter: Vec<u8>, maximum_frame_length: usize, allow_truncation: bool, ) -> Flow<Vec<u8>, Vec<u8>>
Splits the byte stream on delimiter, stripping the delimiter from each emitted frame.
Fails the stream once maximum_frame_length bytes accumulate without a delimiter. When the
stream ends mid-frame, allow_truncation = true emits the trailing bytes as a final frame;
false fails with StreamError. Panics if delimiter is empty or
maximum_frame_length == 0.
Sourcepub fn length_field(
field_length: usize,
field_offset: usize,
maximum_frame_length: usize,
byte_order: FramingByteOrder,
) -> Flow<Vec<u8>, Vec<u8>>
pub fn length_field( field_length: usize, field_offset: usize, maximum_frame_length: usize, byte_order: FramingByteOrder, ) -> Flow<Vec<u8>, Vec<u8>>
Splits length-prefixed frames. The header is field_length bytes (1–4) at field_offset,
interpreted per byte_order; the emitted frame includes the header and the payload.
The decoded length is signed (i32, matching Akka): a 4-byte header with the high bit set
decodes negative and fails the stream. Fails when a decoded frame would exceed
maximum_frame_length. Panics if field_length is not in 1..=4 or
maximum_frame_length == 0.
Sourcepub fn json(maximum_object_length: usize) -> Flow<Vec<u8>, Vec<u8>, NotUsed>
pub fn json(maximum_object_length: usize) -> Flow<Vec<u8>, Vec<u8>, NotUsed>
Extracts top-level JSON objects from a concatenated byte stream, handling objects split across arbitrary chunk boundaries.
Advances past outer array brackets and commas, so both {...}{...} and [{...},{...}]
inputs work. Fails the stream if a single object exceeds maximum_object_length. Panics if
maximum_object_length == 0.