oximedia-bitstream
Bit-level I/O for OxiMedia — a
std-only fork of bitstream-io 4.9.0.
Part of the OxiMedia multimedia framework.
Version: 0.1.7 — 2026-05-16 — 2 tests
Features
- Read and write individual bits and multi-bit integers from any
std::io::Read/std::io::Write - Big-endian and little-endian streams, chosen at compile time as zero-cost type parameters
- Constant-bit-count reads/writes validated at compile time (Rust 1.79+)
- Variable-bit-count reads/writes via
read_var/write_var - Huffman coding traits: [
FromBits] and [ToBits] for encoding/decoding symbols - Struct-level serialisation via [
FromBitStream] / [ToBitStream] derive targets BitRecorder(featurealloc) for recording a write pass and replaying itBitsWrittencounter for measuring output size without a backing writer- No unsafe code (
#![forbid(unsafe_code)])
Usage
[]
= { = "0.1.7" }
Reading bits
use Cursor;
use ;
let data = ;
let mut r = endian;
// Compile-time validated (requires Rust 1.79+)
let high: u8 = r..unwrap;
assert_eq!;
// Runtime variable width
let low: u8 = r.read_var.unwrap;
assert_eq!;
Writing bits
use ;
let mut output = Vecnew;
let mut w = endian;
w..unwrap;
w..unwrap;
w.byte_align.unwrap;
assert_eq!;
Little-endian streams
use Cursor;
use ;
let data = ;
let mut r = endian;
// Bits are read LSB first in little-endian mode
let low: u8 = r..unwrap;
assert_eq!;
API Overview
| Type | Role |
|---|---|
BitReader<R, E> |
Bit-level reader wrapping any io::Read |
BitWriter<W, E> |
Bit-level writer wrapping any io::Write |
ByteReader<R, E> |
Whole-byte reader wrapping any io::Read |
ByteWriter<W, E> |
Whole-byte writer wrapping any io::Write |
BitRecorder<N, E> |
Records bits for replay (requires alloc) |
BitsWritten |
Counts bits without backing storage |
BigEndian / LittleEndian |
Zero-sized endianness type parameters |
Feature Flags
| Flag | Default | Effect |
|---|---|---|
std |
yes | Enables the alloc feature |
alloc |
via std |
Enables BitRecorder |
Upstream Attribution
Derived from bitstream-io 4.9.0
by Brian Langenberger (Apache-2.0 / MIT).
The OxiMedia fork removes the core2 / no_std shim and adopts workspace
conventions (version, authors, lint configuration).
Status
Alpha — API may change between minor versions.
License
Apache-2.0 / MIT — Copyright 2017 Brian Langenberger; 2024-2026 COOLJAPAN OU (Team Kitasan)