pub struct ChunkWriter { /* private fields */ }Expand description
Stateless-per-message outbound chunk writer (§5.3): serializes a
Message into chunk bytes at the current chunk size.
Simple, always-correct strategy: the first chunk is always Type 0 (full absolute-timestamp header) and every continuation chunk is Type 3 (0-byte header, inheriting everything). This is spec-valid — Type 1/2’s more compact delta-based headers are a size optimisation this writer does not perform.
Implementations§
Source§impl ChunkWriter
impl ChunkWriter
Sourcepub fn set_chunk_size(&mut self, n: u32)
pub fn set_chunk_size(&mut self, n: u32)
Update the chunk size used for subsequent ChunkWriter::write
calls (called on sending a Set Chunk Size protocol control message,
§5.4.1). Capped at MAX_CHUNK_SIZE (the floor-of-1 is applied in
ChunkWriter::write itself).
Sourcepub fn write(&mut self, msg: &Message) -> Vec<u8> ⓘ
pub fn write(&mut self, msg: &Message) -> Vec<u8> ⓘ
Serialize msg into chunk bytes at the current chunk size: a Type 0
first chunk carrying up to chunk_size payload bytes, then Type 3
continuation chunks for the remainder.
§Panics
If msg.chunk_stream_id is outside the basic header’s encodable
range (2..=65599) — the same precondition BasicHeader::serialize_into
enforces. Every chunk_stream_id produced by ChunkAssembler::push
satisfies this (BasicHeader::parse never yields one outside the
range), so a Message round-tripped from the assembler never panics
here; callers building a Message from scratch must respect it.
Trait Implementations§
Source§impl Clone for ChunkWriter
impl Clone for ChunkWriter
Source§fn clone(&self) -> ChunkWriter
fn clone(&self) -> ChunkWriter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more