pub struct PerfectRng32 { /* private fields */ }
Implementations§
Source§impl PerfectRng32
impl PerfectRng32
Sourcepub fn new(range: u32, seed: u32, rounds: usize) -> Self
pub fn new(range: u32, seed: u32, 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: u32) -> Self
pub fn from_range(range: u32) -> 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 PerfectRng32
impl Debug for PerfectRng32
Source§impl Default for PerfectRng32
impl Default for PerfectRng32
Source§fn default() -> PerfectRng32
fn default() -> PerfectRng32
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PerfectRng32
impl RefUnwindSafe for PerfectRng32
impl Send for PerfectRng32
impl Sync for PerfectRng32
impl Unpin for PerfectRng32
impl UnwindSafe for PerfectRng32
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