#write #bit #binary #byte-vector #bit-length #bit-level #bitwriter

no-std rust-bitwriter

rust-bitwriter is a library to write data on bit level into byte vector. It is intended to complement https://github.com/irauta/bitreader with a writer part. It supports standard signed/unsigned integer types, such as u32, i64. “Unusual” types, such as i5 or u22, are also supported.

1 unstable release

Uses old Rust 2015

0.0.1 Sep 11, 2023

#9 in #bit-length

Download history 1/week @ 2024-11-13 5/week @ 2024-11-20 9/week @ 2024-11-27 13/week @ 2024-12-04 22/week @ 2024-12-11 6/week @ 2024-12-18 27/week @ 2025-01-01 2/week @ 2025-01-08 10/week @ 2025-01-15 2/week @ 2025-01-22 10/week @ 2025-02-05 44/week @ 2025-02-12 8/week @ 2025-02-19 40/week @ 2025-02-26

102 downloads per month
Used in 4 crates (2 directly)

MIT license

12KB
200 lines

rust-bitwriter

rust-bitwriter is a Rust library to write bits into a byte vector.

It is intended to complement https://github.com/irauta/bitreader with a writer part. It supports standard signed/unsigned integer types, such as u32, i64, as well as integers of any bit length (up to 64), such as i28.

This example shows how to write a bool, an u28 and an i28 into a byte vector:

let mut writer = BitWriter::new();

writer.write_bool(true).expect("failed to write bool");
writer.write_u32(178956970, 28).expect("failed to write u28");
writer.write_i32(-22369622, 28).expect("failed to write i28");

writer.close().expect("failed to close byte vector");
let buffer = writer.data();

This is my first Rust project, so there might be some obvious issues. If you have some suggestions or improvements, please create a PR!

Dependencies

~4KB