βββββ βββββ βββββ βββββββββββ βββββ
βββββ βββββ βββββ βββββββββββββ βββββ
ββββ ββββ ββββββββ ββββββ ββββββββ ββββ ββββ βββββ ββββ βββββββ ββββββ
ββββ ββββ βββββββββ ββββββββββββββββββ βββββββββββ βββββ ββββ βββββββ ββββββββ
ββββ ββββ ββββ ββββββββββββ ββββ βββ ββββββββββββ ββββ ββββ ββββ ββββββββ
ββββ ββββ ββββ βββββββββββ ββββ ββββ ββββ ββββ ββββ ββββ ββββββββββ
ββββββββββ ββββββββ ββββββββ βββββ βββββββββββ βββββββββ βββββββ ββββββββ
ββββββββ ββββββββ ββββββ βββββ βββββββββββ ββββββββ βββββ ββββββ
βββ ββββ
ββββββββ
ββββββ
Bit manipulation for dummies
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);
}
}
}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.
Add UberByte to your project with:
cargo add uberbyte - 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
- A developer friendly implementation of a byte array
Check out the Examples for some basic usage scenarios.
If you want to contribute you can do this in many ways
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.
Found a bug? Missing a feature?
Create a ticket at our (github issues)[https://github.com/dejanfajfar/uberbyte.rs/issues].
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]
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]