pub struct BitReader<E: Endianness, WR, RP: ReadParams = DefaultReadParams> { /* private fields */ }
Expand description
An implementation of BitRead
for a WordRead
with word u64
and of
BitSeek
for a WordSeek
.
This implementation accesses randomly the underlying WordRead
without
any buffering. It is usually slower than
BufBitReader
.
The peek word is u32
. The value returned by
peek_bits
contains at least 32 bits
(extended with zeros beyond end of stream), that is, a full peek word.
The additional type parameter RP
is used to select the parameters for the
instantanous codes, but the casual user should be happy with the default
value. See ReadParams
for more details.
For additional flexibility, this structures implements std::io::Read
.
Note that because of coherence rules it is not possible to implement
std::io::Read
for a generic BitRead
.
Implementations§
Source§impl<E: Endianness, WR, RP: ReadParams> BitReader<E, WR, RP>
impl<E: Endianness, WR, RP: ReadParams> BitReader<E, WR, RP>
Trait Implementations§
Source§impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>, RP: ReadParams> BitRead<BigEndian> for BitReader<BE, WR, RP>
impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>, RP: ReadParams> BitRead<BigEndian> for BitReader<BE, WR, RP>
type Error = <WR as WordRead>::Error
Source§fn skip_bits(&mut self, n_bits: usize) -> Result<(), Self::Error>
fn skip_bits(&mut self, n_bits: usize) -> Result<(), Self::Error>
Skip
n
bits from the stream. Read moreSource§fn read_bits(&mut self, n_bits: usize) -> Result<u64, Self::Error>
fn read_bits(&mut self, n_bits: usize) -> Result<u64, Self::Error>
Read
n
bits and return them in the lowest bits. Read moreSource§fn peek_bits(&mut self, n_bits: usize) -> Result<u32, Self::Error>
fn peek_bits(&mut self, n_bits: usize) -> Result<u32, Self::Error>
Peeks at
n
bits without advancing the stream position.
n
must be nonzero, and at most PeekWord::BITS
.fn copy_to<F: Endianness, W: BitWrite<F>>( &mut self, bit_write: &mut W, n: u64, ) -> Result<(), CopyError<Self::Error, W::Error>>
Source§impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>, RP: ReadParams> BitRead<LittleEndian> for BitReader<LE, WR, RP>
impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>, RP: ReadParams> BitRead<LittleEndian> for BitReader<LE, WR, RP>
type Error = <WR as WordRead>::Error
Source§fn skip_bits(&mut self, n_bits: usize) -> Result<(), Self::Error>
fn skip_bits(&mut self, n_bits: usize) -> Result<(), Self::Error>
Skip
n
bits from the stream. Read moreSource§fn read_bits(&mut self, n_bits: usize) -> Result<u64, Self::Error>
fn read_bits(&mut self, n_bits: usize) -> Result<u64, Self::Error>
Read
n
bits and return them in the lowest bits. Read moreSource§fn peek_bits(&mut self, n_bits: usize) -> Result<u32, Self::Error>
fn peek_bits(&mut self, n_bits: usize) -> Result<u32, Self::Error>
Peeks at
n
bits without advancing the stream position.
n
must be nonzero, and at most PeekWord::BITS
.fn copy_to<F: Endianness, W: BitWrite<F>>( &mut self, bit_write: &mut W, n: u64, ) -> Result<(), CopyError<Self::Error, W::Error>>
Source§impl<WR: WordSeek, RP: ReadParams> BitSeek for BitReader<BE, WR, RP>
impl<WR: WordSeek, RP: ReadParams> BitSeek for BitReader<BE, WR, RP>
Source§impl<WR: WordSeek, RP: ReadParams> BitSeek for BitReader<LE, WR, RP>
impl<WR: WordSeek, RP: ReadParams> BitSeek for BitReader<LE, WR, RP>
Source§impl<E: Clone + Endianness, WR: Clone, RP: Clone + ReadParams> Clone for BitReader<E, WR, RP>
impl<E: Clone + Endianness, WR: Clone, RP: Clone + ReadParams> Clone for BitReader<E, WR, RP>
Source§impl<E: Endianness, WR, RP: ReadParams> CopyType for BitReader<E, WR, RP>
impl<E: Endianness, WR, RP: ReadParams> CopyType for BitReader<E, WR, RP>
Source§impl<E: Debug + Endianness, WR: Debug, RP: Debug + ReadParams> Debug for BitReader<E, WR, RP>
impl<E: Debug + Endianness, WR: Debug, RP: Debug + ReadParams> Debug for BitReader<E, WR, RP>
Source§impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>> DeltaRead<BigEndian> for BitReader<BigEndian, WR, DefaultReadParams>where
WR::Word: DoubleType + UpcastableInto<u64>,
<WR::Word as DoubleType>::DoubleType: CastableInto<u64>,
impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>> DeltaRead<BigEndian> for BitReader<BigEndian, WR, DefaultReadParams>where
WR::Word: DoubleType + UpcastableInto<u64>,
<WR::Word as DoubleType>::DoubleType: CastableInto<u64>,
Source§impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>> DeltaRead<LittleEndian> for BitReader<LittleEndian, WR, DefaultReadParams>where
WR::Word: DoubleType + UpcastableInto<u64>,
<WR::Word as DoubleType>::DoubleType: CastableInto<u64>,
impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>> DeltaRead<LittleEndian> for BitReader<LittleEndian, WR, DefaultReadParams>where
WR::Word: DoubleType + UpcastableInto<u64>,
<WR::Word as DoubleType>::DoubleType: CastableInto<u64>,
Source§impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>> GammaRead<BigEndian> for BitReader<BigEndian, WR, DefaultReadParams>where
WR::Word: DoubleType + UpcastableInto<u64>,
<WR::Word as DoubleType>::DoubleType: CastableInto<u64>,
impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>> GammaRead<BigEndian> for BitReader<BigEndian, WR, DefaultReadParams>where
WR::Word: DoubleType + UpcastableInto<u64>,
<WR::Word as DoubleType>::DoubleType: CastableInto<u64>,
Source§impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>> GammaRead<LittleEndian> for BitReader<LittleEndian, WR, DefaultReadParams>where
WR::Word: DoubleType + UpcastableInto<u64>,
<WR::Word as DoubleType>::DoubleType: CastableInto<u64>,
impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>> GammaRead<LittleEndian> for BitReader<LittleEndian, WR, DefaultReadParams>where
WR::Word: DoubleType + UpcastableInto<u64>,
<WR::Word as DoubleType>::DoubleType: CastableInto<u64>,
Source§impl<E: Endianness, WR, RP: ReadParams> MemDbgImpl for BitReader<E, WR, RP>
impl<E: Endianness, WR, RP: ReadParams> MemDbgImpl for BitReader<E, WR, RP>
fn _mem_dbg_rec_on( &self, _memdbg_writer: &mut impl Write, _memdbg_total_size: usize, _memdbg_max_depth: usize, _memdbg_prefix: &mut String, _memdbg_is_last: bool, _memdbg_flags: DbgFlags, ) -> Result
fn _mem_dbg_depth_on( &self, writer: &mut impl Write, total_size: usize, max_depth: usize, prefix: &mut String, field_name: Option<&str>, is_last: bool, padded_size: usize, flags: DbgFlags, ) -> Result<(), Error>
Source§impl<E: Endianness, WR, RP: ReadParams> MemSize for BitReader<E, WR, RP>
impl<E: Endianness, WR, RP: ReadParams> MemSize for BitReader<E, WR, RP>
Source§impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>, RP: ReadParams> Read for BitReader<BE, WR, RP>
impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>, RP: ReadParams> Read for BitReader<BE, WR, RP>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning
how many bytes were read. Read more
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
Like
read
, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
Reads all bytes until EOF in this source, placing them into
buf
. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
Reads all bytes until EOF in this source, appending them to
buf
. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
Reads the exact number of bytes required to fill
buf
. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf
)Pull some bytes from this source into the specified buffer. Read more
Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf
)Reads the exact number of bytes required to fill
cursor
. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Creates a “by reference” adaptor for this instance of
Read
. Read moreSource§impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>, RP: ReadParams> Read for BitReader<LE, WR, RP>
impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>, RP: ReadParams> Read for BitReader<LE, WR, RP>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning
how many bytes were read. Read more
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
Like
read
, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
Reads all bytes until EOF in this source, placing them into
buf
. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
Reads all bytes until EOF in this source, appending them to
buf
. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
Reads the exact number of bytes required to fill
buf
. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf
)Pull some bytes from this source into the specified buffer. Read more
Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf
)Reads the exact number of bytes required to fill
cursor
. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Creates a “by reference” adaptor for this instance of
Read
. Read moreSource§impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>> ZetaRead<BigEndian> for BitReader<BigEndian, WR, DefaultReadParams>where
WR::Word: DoubleType + UpcastableInto<u64>,
<WR::Word as DoubleType>::DoubleType: CastableInto<u64>,
impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>> ZetaRead<BigEndian> for BitReader<BigEndian, WR, DefaultReadParams>where
WR::Word: DoubleType + UpcastableInto<u64>,
<WR::Word as DoubleType>::DoubleType: CastableInto<u64>,
Source§impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>> ZetaRead<LittleEndian> for BitReader<LittleEndian, WR, DefaultReadParams>where
WR::Word: DoubleType + UpcastableInto<u64>,
<WR::Word as DoubleType>::DoubleType: CastableInto<u64>,
impl<E: Error + Send + Sync + 'static, WR: WordRead<Error = E, Word = u64> + WordSeek<Error = E>> ZetaRead<LittleEndian> for BitReader<LittleEndian, WR, DefaultReadParams>where
WR::Word: DoubleType + UpcastableInto<u64>,
<WR::Word as DoubleType>::DoubleType: CastableInto<u64>,
Auto Trait Implementations§
impl<E, WR, RP> Freeze for BitReader<E, WR, RP>where
WR: Freeze,
impl<E, WR, RP> RefUnwindSafe for BitReader<E, WR, RP>
impl<E, WR, RP> Send for BitReader<E, WR, RP>
impl<E, WR, RP> Sync for BitReader<E, WR, RP>
impl<E, WR, RP> Unpin for BitReader<E, WR, RP>
impl<E, WR, RP> UnwindSafe for BitReader<E, WR, RP>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<B> DeltaReadParam<BigEndian> for Bwhere
B: GammaReadParam<BigEndian>,
impl<B> DeltaReadParam<BigEndian> for Bwhere
B: GammaReadParam<BigEndian>,
Source§impl<B> DeltaReadParam<LittleEndian> for Bwhere
B: GammaReadParam<LittleEndian>,
impl<B> DeltaReadParam<LittleEndian> for Bwhere
B: GammaReadParam<LittleEndian>,
fn read_delta_param<const USE_DELTA_TABLE: bool, const USE_GAMMA_TABLE: bool>( &mut self, ) -> Result<u64, <B as BitRead<LittleEndian>>::Error>
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Truncate the current UnsignedInt to a possibly smaller size
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<E, B> ExpGolombRead<E> for B
impl<E, B> ExpGolombRead<E> for B
Source§impl<B> GammaReadParam<BigEndian> for B
impl<B> GammaReadParam<BigEndian> for B
Source§impl<B> GammaReadParam<LittleEndian> for Bwhere
B: BitRead<LittleEndian>,
impl<B> GammaReadParam<LittleEndian> for Bwhere
B: BitRead<LittleEndian>,
fn read_gamma_param<const USE_TABLE: bool>( &mut self, ) -> Result<u64, <B as BitRead<LittleEndian>>::Error>
Source§impl<E, B> GolombRead<E> for Bwhere
E: Endianness,
B: BitRead<E>,
impl<E, B> GolombRead<E> for Bwhere
E: Endianness,
B: BitRead<E>,
Source§impl<T> MemDbg for Twhere
T: MemDbgImpl,
impl<T> MemDbg for Twhere
T: MemDbgImpl,
Source§fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>
fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>
Writes to stderr debug infos about the structure memory usage, expanding
all levels of nested structures.
Source§fn mem_dbg_on(
&self,
writer: &mut impl Write,
flags: DbgFlags,
) -> Result<(), Error>
fn mem_dbg_on( &self, writer: &mut impl Write, flags: DbgFlags, ) -> Result<(), Error>
Writes to a
core::fmt::Write
debug infos about the structure memory
usage, expanding all levels of nested structures.Source§fn mem_dbg_depth(&self, max_depth: usize, flags: DbgFlags) -> Result<(), Error>
fn mem_dbg_depth(&self, max_depth: usize, flags: DbgFlags) -> Result<(), Error>
Writes to stderr debug infos about the structure memory usage as
mem_dbg
, but expanding only up to max_depth
levels of nested structures.Source§fn mem_dbg_depth_on(
&self,
writer: &mut impl Write,
max_depth: usize,
flags: DbgFlags,
) -> Result<(), Error>
fn mem_dbg_depth_on( &self, writer: &mut impl Write, max_depth: usize, flags: DbgFlags, ) -> Result<(), Error>
Writes to a
core::fmt::Write
debug infos about the structure memory
usage as mem_dbg_on
, but expanding only up to
max_depth
levels of nested structures.Source§impl<E, B> MinimalBinaryRead<E> for Bwhere
E: Endianness,
B: BitRead<E>,
impl<E, B> MinimalBinaryRead<E> for Bwhere
E: Endianness,
B: BitRead<E>,
Source§impl<E, B> OmegaRead<E> for Bwhere
E: Endianness,
B: BitRead<E>,
impl<E, B> OmegaRead<E> for Bwhere
E: Endianness,
B: BitRead<E>,
Source§impl<E, B> RiceRead<E> for Bwhere
E: Endianness,
B: BitRead<E>,
impl<E, B> RiceRead<E> for Bwhere
E: Endianness,
B: BitRead<E>,
Source§impl<T> UpcastableFrom<T> for T
impl<T> UpcastableFrom<T> for T
Source§fn upcast_from(value: T) -> T
fn upcast_from(value: T) -> T
Extend the current UnsignedInt to a possibly bigger size.