9 releases (4 breaking)
Uses old Rust 2015
0.5.3 | Nov 5, 2017 |
---|---|
0.5.2 | Nov 4, 2017 |
0.4.0 | Oct 30, 2017 |
0.3.0 | Oct 29, 2017 |
0.1.1 | Oct 28, 2017 |
#179 in #bit
Used in 2 crates
40KB
848 lines
A crate for reading and writing bits from various streams
This crate is unstable. Features may be added or removed without warning. Expect breaking changes.
Reading
use bit_manager::{BitReader, BitRead};
let mut reader = BitReader::new([0b01101110u8, 0b10100000u8].as_ref());
assert_eq!(reader.read_bit()?, false);
assert_eq!(reader.read_bit()?, true);
assert_eq!(reader.read_bit()?, true);
assert_eq!(reader.read_byte()?, 0b01110101);
Writing
use bit_manager::{BitWriter, BitWrite};
let mut writer = BitWriter::new(Vec::new());
writer.write_bit(false)?;
writer.write_bit(true)?;
writer.write_bit(true)?;
writer.write_byte(0b01110101)?;
assert_eq!(writer.into_inner()?, [0b01101110u8, 0b10100000u8]);