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

Wrapper around compressed data, enabling a Decompressor to read bit-level information and maintain its position in the data.

It does this with a slice of usizes representing the data and maintaining

  • an index into the slice and
  • a bit index from 0 to usize::BITS within the current usize.

The reader is consider is considered “aligned” if the current bit index is byte-aligned; e.g. bit_idx % 8 == 0.

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 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().

Sets the bit reader’s current position to the specified bit index. Will NOT check whether the resulting position is in bounds or not.

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

Wraps seek_to.

Skips backward n bits. Will panic if the resulting position is out of bounds.

Wraps seek_to.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Converts to this type from the input type.

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

Returns the argument unchanged.

Calls U::from(self).

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

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.