rust-bitwriter

Crates.iorust-bitwriter
lib.rsrust-bitwriter
version0.0.1
sourcesrc
created_at2023-09-11 02:39:56.327464
updated_at2023-09-11 02:39:56.327464
description`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.
homepagehttps://github.com/Danaozhong/rust-bitwriter
repositoryhttps://github.com/Danaozhong/rust-bitwriter
max_upload_size
id969161
size12,913
Clemens (Danaozhong)

documentation

https://docs.rs/rust-bitwriter

README

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!

Commit count: 12

cargo fmt