bitrw
Bit-level Rust IO
bitrw offers bit-level reading and writing for Rust Read
and Write
types.
It was extracted from my gcstool project.
Synopsis
extern crate bitrw;
use ;
// Something implementing io::Write
let buf: = Vec new;
let mut writer = new;
let mut bits_written = writer.write_bit?;
bits_written += writer.write_bits?;
bits_written += writer.write_bits?;
bits_written += writer.flush?; // returns u64 indicating the number of bits of padding.
assert_eq!;
// Or io::Read, and optionally io::Seek for seeking by bit position.
let mut reader = new;
let bit = reader.read_bit?; // u8, 0 or 1
let rest_of_byte = reader.read_bits?; // u64 of remainder.
let bits = reader.read_bits?;
assert_eq!;
assert_eq!;
assert_eq!;