0.1.2 |
|
---|---|
0.1.1 |
|
0.1.0 |
|
#15 in #unaligned
13KB
355 lines
fleabit
fleabit is a Rust crate that allows reading and writing unaligned bytes. It provides a simple API and is built on top of bitvec.
It is intended for a multiplayer game library that's in development.
Note that this crate is probably not production ready. Use at your own discretion.
Example
use fleabit::{FleaBitReader, FleaBitWriter};
let mut writer = FleaBitWriter::new();
writer.bool(false);
assert_eq!(writer.to_string(), ".......0");
writer.u8(135);
assert_eq!(writer.to_string(), "00001110_.......1");
let bytes = writer.into_vec();
assert_eq!(bytes, vec![0x0e, 0x01]);
let mut reader = FleaBitReader::from_slice(&bytes);
assert_eq!(reader.bool(), false);
assert_eq!(reader.u8(), 135);
License
fleabit is licensed under either the MIT license or the Apache-2.0 license, at your discretion.
Dependencies
~1MB
~23K SLoC