Struct bitpack::BitPack
[−]
[src]
pub struct BitPack<B> { /* fields omitted */ }
Methods
impl<B> BitPack<B>
[src]
fn new(buff: B) -> Self
fn sum_bits(&self) -> usize
fn with_cursor(&mut self, cursor: usize) -> &mut Self
fn with_bits(&mut self, bits: usize) -> &mut Self
impl<B: AsRef<[u8]>> BitPack<B>
[src]
fn as_slice(&self) -> &[u8]
impl<'a> BitPack<&'a mut [u8]>
[src]
fn write(&mut self, value: u32, bits: usize) -> Result<(), usize>
use bitpack::BitPack; let mut buff = [0; 2]; { let mut bitpack = BitPack::<&mut [u8]>::new(&mut buff); bitpack.write(10, 4).unwrap(); bitpack.write(1021, 10).unwrap(); bitpack.write(3, 2).unwrap(); } assert_eq!(buff, [218, 255]);
impl<'a> BitPack<&'a [u8]>
[src]
fn read(&mut self, bits: usize) -> Result<u32, usize>
use bitpack::BitPack; let mut buff = [218, 255]; let mut bitpack = BitPack::<&[u8]>::new(&buff); assert_eq!(bitpack.read(4).unwrap(), 10); assert_eq!(bitpack.read(10).unwrap(), 1021); assert_eq!(bitpack.read(2).unwrap(), 3);
Trait Implementations
impl<B: Clone> Clone for BitPack<B>
[src]
fn clone(&self) -> BitPack<B>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<B: Debug> Debug for BitPack<B>
[src]
impl<B: PartialEq> PartialEq for BitPack<B>
[src]
fn eq(&self, __arg_0: &BitPack<B>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &BitPack<B>) -> bool
This method tests for !=
.