Crate bigwise [] [src]

Bitwise operations on fixed-size, arbitrary big buffer of bytes.

The primitive types u8, u16, u32 and u64 are very useful types, when one needs to perform boolean algebra on many bits at once (bitwise operations).

This crate complements these primitive types, with subsequent power-of-two sizes: Bw128, Bw256, etc. These types are all Copy (that is, they can be trivially copied as raw memory), and their size is really the size given by their names (Bw256 takes 256 bits). You may be quickly limited by Rust's default stack size if you store these types directly on the stack. Don't forget to box your values if you want them to live on the heap!

If the types provided are not enough, you can easily define your own by creating an alias to a BwPair<X>. Only power-of-two sizes are supported.

Examples

use bigwise::{Bigwise, Bw128};
let b1 = Bw128::from_bytes(&[0b00110110, 0b10001101]);
let b2 = b1 << 90;
let b3 = Bw128::full() >> 60;
let b4 = b1.rotate_right(5);
let b5 = (b2 & !b3) | b4;
print!("{:?}", b5);

Structs

BitsIter

An iterator over the bits.

Bw64

A Bigwise type composed of 64 bits.

BwPair

Combines two Bigwise to form a bigger one.

Traits

Bigwise

A type that supports bitwise operations.

Type Definitions

Bw128

A Bigwise type composed of 128 bits.

Bw256

A Bigwise type composed of 256 bits.

Bw512

A Bigwise type composed of 512 bits.

Bw128k

A Bigwise type composed of 131.072 bits.

Bw16k

A Bigwise type composed of 16.384 bits.

Bw1M

A Bigwise type composed of 1.048.576 bits.

Bw1k

A Bigwise type composed of 1024 bits.

Bw256k

A Bigwise type composed of 262.144 bits.

Bw2k

A Bigwise type composed of 2.048 bits.

Bw32k

A Bigwise type composed of 32.768 bits.

Bw4k

A Bigwise type composed of 4.096 bits.

Bw512k

A Bigwise type composed of 524.288 bits.

Bw64k

A Bigwise type composed of 65.536 bits.

Bw8k

A Bigwise type composed of 8.192 bits.