bitcursor 1.0.0

Keeps track of the bit position for an in wrapped memory buffer, and provides it with a read, seek implementation. Also applys a new trait called ReadBits which allows reading types that implement Unit from the cursor.
Documentation
  • Coverage
  • 42.42%
    14 out of 33 items documented13 out of 31 items with examples
  • Size
  • Source code size: 177.62 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.75 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • barrelll

BitCursor

Crates.io docs MIT/Apache


Keeps track of the bit position for an in wrapped memory buffer, and provides it with a read, write, and seek implementation. Also provides some traits for reading any size primitive, unsigned or signed integer ReadBits && ForceReadBits

Examples

Read a u16 from a list of u8's, first from bit position 0 and then from bit position 2 + cursor position 1.

use {BitCursor, Readbits};

let data: [u8; 4] = [0b01101010, 0b11110001, 0b01110100, 0b10100001];
let mut bcurs = BitCursor::new(&data[..]);
let r = bcurs.read_bits::<u16>().unwrap();
assert_eq!(0b0110101011110001 as u16, r);
let _ = bcurs.seek(SeekFrom::Start(10));
let r = bcurs.read_bits::<u16>().unwrap();
assert_eq!(0b1100010111010010 as u16, r);

To see more examples see the tests module