pub struct PerfectRng { /* private fields */ }
Implementations§
Source§impl PerfectRng
impl PerfectRng
Sourcepub fn new(range: u64, seed: u64, rounds: usize) -> Self
pub fn new(range: u64, seed: u64, rounds: usize) -> Self
Create a new perfect cipher with a specific range, seed, and rounds.
Use PerfectRng::from_range
to use the default seed and rounds.
range
: The number of possible values. In other words, the highest value you will try to shuffle. For example, this would be 2**32-1 for an IPv4 address.seed
: The seed used for randomization.rounds
: The amount of times the randomization is done, to make it more random. Recommended value is either 3 or 4, depending on your performance/quality needs.
let perfect_rng = PerfectRng::new(10, rand::random(), 4);
Sourcepub fn from_range(range: u64) -> Self
pub fn from_range(range: u64) -> Self
Create a new PerfectRng
with a random seed and default rounds.
let perfect_rng = PerfectRng::from_range(2u64.pow(32));
Trait Implementations§
Source§impl Debug for PerfectRng
impl Debug for PerfectRng
Source§impl Default for PerfectRng
impl Default for PerfectRng
Source§fn default() -> PerfectRng
fn default() -> PerfectRng
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PerfectRng
impl RefUnwindSafe for PerfectRng
impl Send for PerfectRng
impl Sync for PerfectRng
impl Unpin for PerfectRng
impl UnwindSafe for PerfectRng
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more