Struct bc_crypto::SeededRandomNumberGenerator
source · pub struct SeededRandomNumberGenerator { /* private fields */ }Expand description
A random number generator that can be used as a source of deterministic pseudo-randomness for testing purposes.
Implementations§
source§impl SeededRandomNumberGenerator
impl SeededRandomNumberGenerator
sourcepub fn new(seed: [u64; 4]) -> Self
pub fn new(seed: [u64; 4]) -> Self
Creates a new seeded random number generator.
The seed should be a 256-bit value, represented as an array of 4 64-bit integers. For the output distribution to look random, the seed should not have any obvious patterns, like all zeroes or all ones.
This is not cryptographically secure, and should only be used for testing purposes.
pub fn next_u64(&mut self) -> u64
Trait Implementations§
source§impl RandomNumberGenerator for SeededRandomNumberGenerator
impl RandomNumberGenerator for SeededRandomNumberGenerator
source§fn random_data(&mut self, size: usize) -> Vec<u8>
fn random_data(&mut self, size: usize) -> Vec<u8>
Returns a vector of random bytes of the given size.
source§fn fill_random_data(&mut self, data: &mut [u8])
fn fill_random_data(&mut self, data: &mut [u8])
Fills the given buffer with random bytes.
source§fn next_with_upper_bound<T>(&mut self, upper_bound: T) -> Twhere
T: PrimInt + Unsigned + NumCast + FromPrimitive + AsPrimitive<u128> + OverflowingMul + Shl<usize, Output = T> + Shr<usize, Output = T> + WrappingSub + OverflowingAdd + Widening,
fn next_with_upper_bound<T>(&mut self, upper_bound: T) -> Twhere T: PrimInt + Unsigned + NumCast + FromPrimitive + AsPrimitive<u128> + OverflowingMul + Shl<usize, Output = T> + Shr<usize, Output = T> + WrappingSub + OverflowingAdd + Widening,
Returns a random value that is less than the given upper bound. Read more
source§fn next_in_range<T>(&mut self, range: &Range<T>) -> Twhere
T: PrimInt + FromPrimitive + AsPrimitive<u128> + OverflowingMul + Shl<usize, Output = T> + Shr<usize, Output = T> + HasMagnitude + OverflowingAdd,
fn next_in_range<T>(&mut self, range: &Range<T>) -> Twhere T: PrimInt + FromPrimitive + AsPrimitive<u128> + OverflowingMul + Shl<usize, Output = T> + Shr<usize, Output = T> + HasMagnitude + OverflowingAdd,
Returns a random value within the specified range, using the given
generator as a source for randomness. Read more
fn next_in_closed_range<T>(&mut self, range: &RangeInclusive<T>) -> Twhere T: PrimInt + FromPrimitive + AsPrimitive<u128> + OverflowingMul + Shl<usize, Output = T> + Shr<usize, Output = T> + HasMagnitude,
Auto Trait Implementations§
impl RefUnwindSafe for SeededRandomNumberGenerator
impl Send for SeededRandomNumberGenerator
impl Sync for SeededRandomNumberGenerator
impl Unpin for SeededRandomNumberGenerator
impl UnwindSafe for SeededRandomNumberGenerator
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