Skip to main content

BitReaderExt

Trait BitReaderExt 

Source
pub trait BitReaderExt<'de>: BitReader<'de> {
    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn read_bytes_into(
        &mut self,
        dst: impl AsMut<[u8]>,
    ) -> Result<usize, Self::Error> { ... }
    fn read_bytes_array<const N: usize>(
        &mut self,
    ) -> Result<[u8; N], Self::Error> { ... }
    fn unpack<T>(
        &mut self,
        args: <T as BitUnpack<'de>>::Args,
    ) -> Result<T, Self::Error>
       where T: BitUnpack<'de> { ... }
    fn unpack_iter<'a, T>(
        &'a mut self,
        args: <T as BitUnpack<'de>>::Args,
    ) -> impl Iterator<Item = Result<T, Self::Error>> + 'a
       where T: BitUnpack<'de>,
             <T as BitUnpack<'de>>::Args: Clone + 'a { ... }
    fn unpack_as<T, As>(
        &mut self,
        args: <As as BitUnpackAs<'de, T>>::Args,
    ) -> Result<T, Self::Error>
       where As: BitUnpackAs<'de, T> + ?Sized { ... }
    fn unpack_iter_as<'a, T, As>(
        &'a mut self,
        args: <As as BitUnpackAs<'de, T>>::Args,
    ) -> impl Iterator<Item = Result<T, Self::Error>> + 'a
       where As: BitUnpackAs<'de, T> + ?Sized,
             <As as BitUnpackAs<'de, T>>::Args: Clone + 'a { ... }
    fn as_mut(&mut self) -> &mut Self { ... }
    fn map_err<F>(self, f: F) -> MapErr<Self, F>
       where Self: Sized { ... }
    fn tee<W>(self, writer: W) -> Tee<Self, W>
       where Self: Sized,
             W: BitWriter { ... }
    fn checkpoint(self) -> Checkpoint<Self>
       where Self: Sized { ... }
    fn join<R>(self, next: R) -> Join<Self, R>
       where Self: Sized,
             R: BitReader<'de> { ... }
}
Expand description

Extension helper for BitReader.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns wheather the reader is empty

Source

fn read_bytes_into( &mut self, dst: impl AsMut<[u8]>, ) -> Result<usize, Self::Error>

Reads dst.len() bytes into given byte slice

Source

fn read_bytes_array<const N: usize>(&mut self) -> Result<[u8; N], Self::Error>

Read N bytes and return array

Source

fn unpack<T>( &mut self, args: <T as BitUnpack<'de>>::Args, ) -> Result<T, Self::Error>
where T: BitUnpack<'de>,

Unpack value witg args using its BitUnpack implementation

Source

fn unpack_iter<'a, T>( &'a mut self, args: <T as BitUnpack<'de>>::Args, ) -> impl Iterator<Item = Result<T, Self::Error>> + 'a
where T: BitUnpack<'de>, <T as BitUnpack<'de>>::Args: Clone + 'a,

Return iterator that unpacks values with args using BitUnpack implementation

Source

fn unpack_as<T, As>( &mut self, args: <As as BitUnpackAs<'de, T>>::Args, ) -> Result<T, Self::Error>
where As: BitUnpackAs<'de, T> + ?Sized,

Unpack value with args using an adapter.

This approach is heavily inspired by serde_with. Please, read their docs for more usage examples.

Source

fn unpack_iter_as<'a, T, As>( &'a mut self, args: <As as BitUnpackAs<'de, T>>::Args, ) -> impl Iterator<Item = Result<T, Self::Error>> + 'a
where As: BitUnpackAs<'de, T> + ?Sized, <As as BitUnpackAs<'de, T>>::Args: Clone + 'a,

Returns iterator that unpacks values with args using an adapter.

This approach is heavily inspired by serde_with. Please, read their docs for more usage examples.

Source

fn as_mut(&mut self) -> &mut Self

Borrows reader, rather than consuming it.

Source

fn map_err<F>(self, f: F) -> MapErr<Self, F>
where Self: Sized,

Map Error by given closure

Source

fn tee<W>(self, writer: W) -> Tee<Self, W>
where Self: Sized, W: BitWriter,

Mirror all read data to given writer as well.

Source

fn checkpoint(self) -> Checkpoint<Self>
where Self: Sized,

Source

fn join<R>(self, next: R) -> Join<Self, R>
where Self: Sized, R: BitReader<'de>,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'de, T> BitReaderExt<'de> for T
where T: BitReader<'de> + ?Sized,