pub trait BitRead {
Show 14 methods // Required methods fn read_bit(&mut self) -> Result<bool>; fn read<U>(&mut self, bits: u32) -> Result<U> where U: Numeric; fn read_signed<S>(&mut self, bits: u32) -> Result<S> where S: SignedNumeric; fn read_to<V>(&mut self) -> Result<V> where V: Primitive; fn skip(&mut self, bits: u32) -> Result<()>; fn byte_aligned(&self) -> bool; fn byte_align(&mut self); // Provided methods fn read_bytes(&mut self, buf: &mut [u8]) -> Result<()> { ... } fn read_to_bytes<const SIZE: usize>(&mut self) -> Result<[u8; SIZE]> { ... } fn read_to_vec(&mut self, bytes: usize) -> Result<Vec<u8>> { ... } fn read_unary0(&mut self) -> Result<u32> { ... } fn read_unary1(&mut self) -> Result<u32> { ... } fn parse<F: FromBitStream>(&mut self) -> Result<F, F::Error> { ... } fn parse_with<F: FromBitStreamWith>( &mut self, context: &F::Context ) -> Result<F, F::Error> { ... }
}
Expand description

A trait for anything that can read a variable number of potentially un-aligned values from an input stream

Required Methods§

source

fn read_bit(&mut self) -> Result<bool>

Reads a single bit from the stream. true indicates 1, false indicates 0

Errors

Passes along any I/O error from the underlying stream.

source

fn read<U>(&mut self, bits: u32) -> Result<U>where U: Numeric,

Reads an unsigned value from the stream with the given number of bits.

Errors

Passes along any I/O error from the underlying stream. Also returns an error if the output type is too small to hold the requested number of bits.

source

fn read_signed<S>(&mut self, bits: u32) -> Result<S>where S: SignedNumeric,

Reads a twos-complement signed value from the stream with the given number of bits.

Errors

Passes along any I/O error from the underlying stream. Also returns an error if the output type is too small to hold the requested number of bits.

source

fn read_to<V>(&mut self) -> Result<V>where V: Primitive,

Reads whole value from the stream whose size in bits is equal to its type’s size.

Errors

Passes along any I/O error from the underlying stream.

source

fn skip(&mut self, bits: u32) -> Result<()>

Skips the given number of bits in the stream. Since this method does not need an accumulator, it may be slightly faster than reading to an empty variable. In addition, since there is no accumulator, there is no upper limit on the number of bits which may be skipped. These bits are still read from the stream, however, and are never skipped via a seek method.

Errors

Passes along any I/O error from the underlying stream.

source

fn byte_aligned(&self) -> bool

Returns true if the stream is aligned at a whole byte.

source

fn byte_align(&mut self)

Throws away all unread bit values until the next whole byte. Does nothing if the stream is already aligned.

Provided Methods§

source

fn read_bytes(&mut self, buf: &mut [u8]) -> Result<()>

Completely fills the given buffer with whole bytes. If the stream is already byte-aligned, it will map to a faster read_exact call. Otherwise it will read bytes individually in 8-bit increments.

Errors

Passes along any I/O error from the underlying stream.

source

fn read_to_bytes<const SIZE: usize>(&mut self) -> Result<[u8; SIZE]>

👎Deprecated since 1.8.0: use read_to() method instead

Completely fills a whole buffer with bytes and returns it. If the stream is already byte-aligned, it will map to a faster read_exact call. Otherwise it will read bytes individually in 8-bit increments.

Errors

Passes along any I/O error from the underlying stream.

source

fn read_to_vec(&mut self, bytes: usize) -> Result<Vec<u8>>

Completely fills a vector of bytes and returns it. If the stream is already byte-aligned, it will map to a faster read_exact call. Otherwise it will read bytes individually in 8-bit increments.

Errors

Passes along any I/O error from the underlying stream.

source

fn read_unary0(&mut self) -> Result<u32>

Counts the number of 1 bits in the stream until the next 0 bit and returns the amount read. Because this field is variably-sized and may be large, its output is always a u32 type.

Errors

Passes along any I/O error from the underlying stream.

source

fn read_unary1(&mut self) -> Result<u32>

Counts the number of 0 bits in the stream until the next 1 bit and returns the amount read. Because this field is variably-sized and may be large, its output is always a u32 type.

Errors

Passes along any I/O error from the underlying stream.

source

fn parse<F: FromBitStream>(&mut self) -> Result<F, F::Error>

Parses and returns complex type

source

fn parse_with<F: FromBitStreamWith>( &mut self, context: &F::Context ) -> Result<F, F::Error>

Parses and returns complex type with context

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<R: Read, E: Endianness> BitRead for BitReader<R, E>