pub struct InflateReader<'a> { /* private fields */ }Expand description
Streaming zlib reader: decompresses input incrementally into a small
accumulation buffer, so a caller can parse length-delimited records as they
become available and discard consumed bytes — peak memory stays ~the largest
single record being buffered, not the whole decompressed blob.
Usage: ensure(n) to make ≥ n bytes available, read from available(), then
consume(k). The buffer is compacted (consumed prefix dropped) as it grows.
Implementations§
Source§impl<'a> InflateReader<'a>
impl<'a> InflateReader<'a>
pub fn new(input: &'a [u8], max: u64) -> Self
Sourcepub fn ensure(&mut self, need: usize) -> Result<bool>
pub fn ensure(&mut self, need: usize) -> Result<bool>
Ensure at least need unparsed bytes are buffered, decompressing more as
required. Returns Ok(false) if the stream ends before reaching need.
Sourcepub fn is_done(&self) -> bool
pub fn is_done(&self) -> bool
True once the stream is fully decompressed and all bytes consumed.
Sourcepub fn total_out(&self) -> u64
pub fn total_out(&self) -> u64
Total decompressed bytes produced so far. After the stream ends this is the blob’s exact inflated size.
Sourcepub fn compressed_progress(&self) -> (usize, usize)
pub fn compressed_progress(&self) -> (usize, usize)
Compressed input consumed so far plus the input’s full length. The ratio lets callers extrapolate totals (e.g. record counts) from a prefix without a second pass over the blob.
Sourcepub fn stream_ended(&self) -> bool
pub fn stream_ended(&self) -> bool
Whether zlib reported a proper stream end (terminator + adler32
checksum). An EOF (ensure returning false) without this means the
input was truncated, not finished.