5 unstable releases

0.6.1 Oct 3, 2023
0.6.0 Sep 30, 2023
0.5.0 Sep 25, 2023
0.0.2 Sep 24, 2023
0.0.1 Sep 21, 2023

#54 in Parser tooling

Download history 2/week @ 2024-02-22 2/week @ 2024-02-29 13/week @ 2024-03-28 6/week @ 2024-04-04 87/week @ 2024-04-11 3/week @ 2024-04-18

109 downloads per month

MIT license

32KB
543 lines

 █████  █████ █████                        ███████████              █████            
░░███  ░░███ ░░███                        ░░███░░░░░███            ░░███             
 ░███   ░███  ░███████   ██████  ████████  ░███    ░███ █████ ████ ███████    ██████ 
 ░███   ░███  ░███░░███ ███░░███░░███░░███ ░██████████ ░░███ ░███ ░░░███░    ███░░███
 ░███   ░███  ░███ ░███░███████  ░███ ░░░  ░███░░░░░███ ░███ ░███   ░███    ░███████ 
 ░███   ░███  ░███ ░███░███░░░   ░███      ░███    ░███ ░███ ░███   ░███ ███░███░░░  
 ░░████████   ████████ ░░██████  █████     ███████████  ░░███████   ░░█████ ░░██████ 
  ░░░░░░░░   ░░░░░░░░   ░░░░░░  ░░░░░     ░░░░░░░░░░░    ░░░░░███    ░░░░░   ░░░░░░  
                                                         ███ ░███                    
                                                        ░░██████                     
                                                         ░░░░░░                      

Bit manipulation for dummies

Rust Crates.io docs.rs

use uberbyte::UberByte;

fn main() {
    let my_byte: UberByte = UberByte::from(42);

    println!("{:b}", my_byte);
    for index in 0..7 {
        if my_byte.is_bit_set(index) {
            println!("Bit on position {} is set", index);
        } else {
            println!("Bit on position {} is not set", index);
        }
    }
}

📖 Backstory

When working with a hardware interface I found it always tedious to work with individual bits. Checking if one or the other is set and setting them in return to communicate with the hardware.

So to make my life easier and add some convenience to the whole matter I made this.

🚀 Getting started

Add UberByte to your project with:

cargo add uberbyte 

🎨 Features

  • Easily determine the state of each bit in the byte
  • Easily change the sate of each bit in the byte
  • Flip all bits in the byte
  • Provide constant bit masks for each bit
  • Provide OR, XOR, AND operations

Usage

Check out the Examples for some basic usage scenarios.

💗 Contributing

If you want to contribute you can do this in many ways

Fork the repository

If you would like to introduce some changes to the project feel free to fork the project and do your changes.

It would then be nice if you create a pull request to reintegrate the changes you made.

Create a ticket

Found a bug? Missing a feature?

Create a ticket at our (github issues)https://github.com/dejanfajfar/uberbyte.rs/issues.

Start a discussion

Any feedback that you do not want to put into the above form can just be dumped int our (github discussion page)https://github.com/dejanfajfar/uberbyte.rs/discussions

🪪 License

MIT

A great overview of the license is given at (tldrlegal.com)https://www.tldrlegal.com/license/mit-license

The license text can be found at (LICENSE)https://github.com/dejanfajfar/uberbyte.rs/blob/main/LICENSE

No runtime deps