pub struct ChunkAssembler { /* private fields */ }Expand description
Stateful inbound chunk reassembler (§5.3): feed inbound bytes, get back
each complete Message as soon as its last chunk arrives.
Maintains per-chunk_stream_id state, so multiple chunk streams may be
interleaved on the same connection (as the wire format requires) and are
each reassembled independently.
Implementations§
Source§impl ChunkAssembler
impl ChunkAssembler
Sourcepub fn set_chunk_size(&mut self, n: u32)
pub fn set_chunk_size(&mut self, n: u32)
Update the chunk size in effect for subsequent chunks (called on
receipt of a Set Chunk Size protocol control message, §5.4.1). Floored
at 1 (a chunk size of 0 would never make progress splitting payload)
and capped at MAX_CHUNK_SIZE, matching
ChunkWriter::set_chunk_size’s floor/cap.
Sourcepub fn push(&mut self, input: &[u8]) -> Result<Vec<Message>, RtmpError>
pub fn push(&mut self, input: &[u8]) -> Result<Vec<Message>, RtmpError>
Feed inbound bytes; returns each complete Message decoded from
the buffer (in arrival order), leaving any trailing partial chunk or
partial message buffered internally for the next call.
Callers that need to react to a message’s side effects (e.g. a Set
Chunk Size protocol control message, §5.4.1) before parsing the
bytes that follow it in the same input — because the sender may
switch to the new chunk size for its very next chunk — should use the
crate-internal incremental feed/next_message pair instead,
dispatching each message immediately. push collects every message
from input under a single, unchanging chunk_size, which
misparses a buffer that itself contains a Set Chunk Size followed by
chunks already framed at the new size (see
ServerSession, which uses the
incremental form for exactly this reason).
§Errors
RtmpError::Malformed on structurally invalid input (e.g. a Type
1/2/3 chunk on a csid that has never seen a Type 0). Never errors
merely because the input ends mid-chunk — that is buffered, not an
error.