https://github.com/dejanfajfar/uberbyte.rs
Bit manipulation for dummies
https://github.com/dejanfajfar/uberbyte.rs
library rust utility utility-library
Last synced: over 1 year ago
JSON representation
Bit manipulation for dummies
- Host: GitHub
- URL: https://github.com/dejanfajfar/uberbyte.rs
- Owner: dejanfajfar
- License: mit
- Created: 2023-09-06T16:22:01.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-29T17:38:23.000Z (over 2 years ago)
- Last Synced: 2025-02-28T04:48:06.031Z (over 1 year ago)
- Topics: library, rust, utility, utility-library
- Language: Rust
- Homepage:
- Size: 85.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
```
█████ █████ █████ ███████████ █████
░░███ ░░███ ░░███ ░░███░░░░░███ ░░███
░███ ░███ ░███████ ██████ ████████ ░███ ░███ █████ ████ ███████ ██████
░███ ░███ ░███░░███ ███░░███░░███░░███ ░██████████ ░░███ ░███ ░░░███░ ███░░███
░███ ░███ ░███ ░███░███████ ░███ ░░░ ░███░░░░░███ ░███ ░███ ░███ ░███████
░███ ░███ ░███ ░███░███░░░ ░███ ░███ ░███ ░███ ░███ ░███ ███░███░░░
░░████████ ████████ ░░██████ █████ ███████████ ░░███████ ░░█████ ░░██████
░░░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░ ░░░░░░░░░░░ ░░░░░███ ░░░░░ ░░░░░░
███ ░███
░░██████
░░░░░░
```
> Bit manipulation for dummies
[](https://github.com/dejanfajfar/uberbyte.rs/actions/workflows/ci.yml) [](https://crates.io/crates/uberbyte) [](https://docs.rs/uberbyte/0.5.0/uberbyte/)
```rust
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:
```shell
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
- A developer friendly implementation of a byte array
# Usage
Check out the [Examples](https://github.com/dejanfajfar/uberbyte.rs/tree/main/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]