Expand description
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]);
Modules§
- buffer
- Provides a way to convert between storing individual bits and storing whole bytes (for use in I/O operations).
- data
- Provides methods for reading and writing data both directly
(using
BitStore
) and indirectly (usingBitConvert
). - io
- Allows the reading and writing of information from streams.
- prelude
- Contains aliases for the most commonly used types.
Structs§
- BitReader
- A wrapper for any type implementing
io::Read
that allows the reading of individual bits - BitWriter
- A wrapper for any type implementing
io::Write
that allows the writing of individual bits
Enums§
- Error
- An enum for possible errors when reading and writing bits
- Precision
- An enum that represents how a stream is terminated
Traits§
Type Aliases§
- Result
- A specialized Result type for bit I/O operations