This workspace contains two crates: rbitpack and bitval. Together, they provide efficient bit manipulation and packing functionalities for Rust projects.
The rbitpack crate provides macros and utilities for packing and unpacking boolean fields into various bit sizes. It is designed to work with structs, allowing for efficient bitwise operations.
The bitval crate provides the Bitfield struct, which allows for efficient storage and manipulation of individual bits. It is used as the underlying data structure for the rbitpack crate.
To get started, clone the repository:
git clone https://github.com/teckmk/bitwise_packable.git
cd bitwise_packableTo build the entire workspace, run:
cargo buildEach crate contains its own set of tests. To run all tests in the workspace, use:
cargo testThe rbitpack crate provides macros for packing and unpacking boolean fields into various bit sizes. It supports custom attributes to handle overflow values and dynamic bit sizes.
Add rbitpack to your Cargo.toml:
[dependencies]
rbitpack = "0.1.0" // Replace with the current versionuse rbitpack::BitwisePackable;
#[derive(BitwisePackable)]
struct Example {
    field1: bool,
    field2: bool,
    field3: bool,
    // ...
}To run tests for rbitpack:
cd rbitpack
cargo testFor more details, see the rbitpack README.
The bitval crate provides the Bitfield struct for efficient bit storage and manipulation. It supports setting and getting individual bits and is used by the rbitpack crate.
Add bitval to your Cargo.toml:
[dependencies]
bitval = "0.1.0" // Replace with the current versionuse bitval::Bitfield;
fn main() {
    let size = 128;
    let mut bitfield = Bitfield::new(size);
    bitfield.set(5, true);
    bitfield.set(10, false);
    let value = bitfield.get(5);
    println!("Value of 5th bit: {}", value); // Output: Value of 5th bit: true
}To run tests for bitval:
cd bitval
cargo testFor more details, see the bitval README.
- 
Create a new branch for your feature:
git checkout -b feature-name
 - 
Make your changes and commit them:
git commit -am "Add new feature" - 
Push your branch to the remote repository:
git push origin feature-name
 - 
Create a pull request on GitHub.
 
Contributions are welcome! Please open an issue or submit a pull request with your changes. Make sure to include tests for any new features or bug fixes.
This project is licensed under the MIT License.
For questions or feedback, please contact me here.