1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
//! 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); //! ``` extern crate rand; #[cfg(test)] extern crate quickcheck; mod bigwise; pub use bigwise::{Bigwise, BitsIter}; mod bw64; pub use bw64::Bw64; mod bwpair; pub use bwpair::BwPair; /// A `Bigwise` type composed of 128 bits. pub type Bw128 = BwPair<Bw64>; /// A `Bigwise` type composed of 256 bits. pub type Bw256 = BwPair<Bw128>; /// A `Bigwise` type composed of 512 bits. pub type Bw512 = BwPair<Bw256>; /// A `Bigwise` type composed of 1024 bits. pub type Bw1k = BwPair<Bw512>; /// A `Bigwise` type composed of 2.048 bits. pub type Bw2k = BwPair<Bw1k>; /// A `Bigwise` type composed of 4.096 bits. pub type Bw4k = BwPair<Bw2k>; /// A `Bigwise` type composed of 8.192 bits. pub type Bw8k = BwPair<Bw4k>; /// A `Bigwise` type composed of 16.384 bits. pub type Bw16k = BwPair<Bw8k>; /// A `Bigwise` type composed of 32.768 bits. pub type Bw32k = BwPair<Bw16k>; /// A `Bigwise` type composed of 65.536 bits. pub type Bw64k = BwPair<Bw32k>; /// A `Bigwise` type composed of 131.072 bits. pub type Bw128k = BwPair<Bw64k>; /// A `Bigwise` type composed of 262.144 bits. pub type Bw256k = BwPair<Bw128k>; /// A `Bigwise` type composed of 524.288 bits. pub type Bw512k = BwPair<Bw256k>; /// A `Bigwise` type composed of 1.048.576 bits. pub type Bw1M = BwPair<Bw512k>; #[cfg(test)] mod tests;