fleabit

Crates.iofleabit
lib.rsfleabit
version0.1.2
sourcesrc
created_at2022-12-12 02:06:34.792844
updated_at2022-12-12 05:12:06.741578
descriptionRead and write unaligned bytes.
homepage
repositoryhttps://github.com/gak/fleabit
max_upload_size
id734610
size25,250
gak (gak)

documentation

README

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.

Commit count: 9

cargo fmt