BitRead

Struct BitRead 

Source
pub struct BitRead<'t> { /* private fields */ }
Expand description

Provides BitRead from a Read.

use bitrw::UseBitRead;
let mut c = std::io::Cursor::new(&[0b00_11_10_1_0, 0b1_110_101_1, 0b1101000]);
let mut r = c.use_bit_read();
assert_eq!(r.read::<u8>(0).unwrap(), 0);
assert_eq!(r.read::<u16>(1).unwrap(), 0);
assert_eq!(r.read::<u32>(1).unwrap(), 1);
assert_eq!(r.read::<u64>(2).unwrap(), 2);
assert_eq!(r.read::<u128>(2).unwrap(), 3);
assert_eq!(r.read::<usize>(3).unwrap(), 4);
assert_eq!(r.read::<u8>(3).unwrap(), 5);
assert_eq!(r.read::<u16>(3).unwrap(), 6);
assert_eq!(r.read::<u32>(8).unwrap(), 0b11010001);

Implementations§

Source§

impl BitRead<'_>

Source

pub fn read<T: UInt>(&mut self, size: u8) -> Result<T>

Little-endian bit read.

Auto Trait Implementations§

§

impl<'t> Freeze for BitRead<'t>

§

impl<'t> !RefUnwindSafe for BitRead<'t>

§

impl<'t> !Send for BitRead<'t>

§

impl<'t> !Sync for BitRead<'t>

§

impl<'t> Unpin for BitRead<'t>

§

impl<'t> !UnwindSafe for BitRead<'t>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.