Crates.io | rust-bitwriter |
lib.rs | rust-bitwriter |
version | 0.0.1 |
source | src |
created_at | 2023-09-11 02:39:56.327464 |
updated_at | 2023-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. |
homepage | https://github.com/Danaozhong/rust-bitwriter |
repository | https://github.com/Danaozhong/rust-bitwriter |
max_upload_size | |
id | 969161 |
size | 12,913 |
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!