pub struct BitReader<'a> { /* private fields */ }
Expand description

BitReader wraps bytes during decompression, enabling a decompressor to read bit-level information and maintain its position in the bytes.

It does this by maintaining

  • a byte index and
  • a bit index from 0-8 within that byte.

The reader is consider is considered “aligned” if the current bit index is 0 or 8 (i.e. at the start or end of the current byte).

Implementations

Returns the reader’s current byte index. Will return an error if the reader is at a misaligned position.

Returns the number of bits between the reader’s current position and the end.

Returns the number of bytes in the reader.

Returns the reader’s current (byte_idx, bit_idx) tuple.

Returns a slice into the next n bytes. Will return an error if there are not enough bytes remaining in the reader or the reader is misaligned.

Returns the next bit. Will return an error if we have reached the end of the reader.

Returns the next n bits. Will return an error if there are not enough bits remaining.

Returns the next bit. Will panic if we have reached the end of the reader. This tends to be much faster than read_one().

Skips forward n bits. Will NOT check whether the resulting position is in bounds or not.

Skips backward n bits. Will panic if the resulting position is less than 0.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.