Skip to main content

InflateReader

Struct InflateReader 

Source
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>

Source

pub fn new(input: &'a [u8], max: u64) -> Self

Source

pub fn available(&self) -> &[u8]

Unparsed decompressed bytes currently buffered.

Source

pub fn consume(&mut self, n: usize)

Mark n already-read bytes as consumed.

Source

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.

Source

pub fn is_done(&self) -> bool

True once the stream is fully decompressed and all bytes consumed.

Source

pub fn total_out(&self) -> u64

Total decompressed bytes produced so far. After the stream ends this is the blob’s exact inflated size.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Drop for InflateReader<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for InflateReader<'a>

§

impl<'a> Freeze for InflateReader<'a>

§

impl<'a> RefUnwindSafe for InflateReader<'a>

§

impl<'a> Send for InflateReader<'a>

§

impl<'a> Sync for InflateReader<'a>

§

impl<'a> Unpin for InflateReader<'a>

§

impl<'a> UnsafeUnpin for InflateReader<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.