Crate bitstream_iosource ·
Traits and helpers for bitstream handling functionality
Bitstream readers are for reading signed and unsigned integer values from a stream whose sizes may not be whole bytes. Bitstream writers are for writing signed and unsigned integer values to a stream, also potentially un-aligned at a whole byte.
Both big-endian and little-endian streams are supported.
The only requirement for wrapped reader streams is that they must
Read trait, and the only requirement
for writer streams is that they must implement the
In addition, reader streams do not consume any more bytes from the underlying reader than necessary, buffering only a single partial byte as needed. Writer streams also write out all whole bytes as they are accumulated.
Readers and writers are also designed to work with integer types of any possible size. Many of Rust’s built-in integer types are supported by default.
Migrating From Pre 1.0.0
There are now
BitWrite traits for bitstream
reading and writing (analogous to the standard library’s
Write traits) which you will also need to import.
The upside to this approach is that library consumers
can now make functions and methods generic over any sort
of bit reader or bit writer, regardless of the underlying
stream byte source or endianness.
pub use read::BitRead;
pub use read::BitReader;
pub use read::ByteRead;
pub use read::ByteReader;
pub use read::HuffmanRead;
pub use write::BitCounter;
pub use write::BitRecorder;
pub use write::BitWrite;
pub use write::BitWriter;
pub use write::ByteWrite;
pub use write::ByteWriter;
pub use write::HuffmanWrite;