Skip to content

This workspace contains two crates: bitpack and bitval. Together, they provide efficient bit manipulation and packing functionalities for Rust projects.

Notifications You must be signed in to change notification settings

teckmk/bitwise_packable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bitwise Packable Workspace

This workspace contains two crates: rbitpack and bitval. Together, they provide efficient bit manipulation and packing functionalities for Rust projects.

Crates

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.

Getting Started

Cloning the Repository

To get started, clone the repository:

git clone https://github.com/teckmk/bitwise_packable.git
cd bitwise_packable

Building the Workspace

To build the entire workspace, run:

cargo build

Running Tests

Each crate contains its own set of tests. To run all tests in the workspace, use:

cargo test

rbitpack Crate

Overview

The 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.

Usage

Add rbitpack to your Cargo.toml:

[dependencies]
rbitpack = "0.1.0" // Replace with the current version

Example

use rbitpack::BitwisePackable;

#[derive(BitwisePackable)]
struct Example {
    field1: bool,
    field2: bool,
    field3: bool,
    // ...
}

Running Tests

To run tests for rbitpack:

cd rbitpack
cargo test

For more details, see the rbitpack README.

bitval Crate

Overview

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.

Usage

Add bitval to your Cargo.toml:

[dependencies]
bitval = "0.1.0" // Replace with the current version

Example

use 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
}

Running Tests

To run tests for bitval:

cd bitval
cargo test

For more details, see the bitval README.

Development

Adding New Features

  1. Create a new branch for your feature:

    git checkout -b feature-name
  2. Make your changes and commit them:

    git commit -am "Add new feature"
  3. Push your branch to the remote repository:

    git push origin feature-name
  4. Create a pull request on GitHub.

Contributing

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.

License

This project is licensed under the MIT License.

Contact

For questions or feedback, please contact me here.

About

This workspace contains two crates: bitpack and bitval. Together, they provide efficient bit manipulation and packing functionalities for Rust projects.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages