pub struct TokioRandomProvider;Expand description
Production random provider using thread-local RNG.
Uses rand::rng() (thread-local, non-cryptographic) for efficient
random number generation in production environments.
§Example
use moonpool_core::{RandomProvider, TokioRandomProvider};
let random = TokioRandomProvider::new();
let value: u64 = random.random();
let in_range = random.random_range(1..100);Implementations§
Trait Implementations§
Source§impl Clone for TokioRandomProvider
impl Clone for TokioRandomProvider
Source§fn clone(&self) -> TokioRandomProvider
fn clone(&self) -> TokioRandomProvider
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for TokioRandomProvider
impl Default for TokioRandomProvider
Source§fn default() -> TokioRandomProvider
fn default() -> TokioRandomProvider
Returns the “default value” for a type. Read more
Source§impl RandomProvider for TokioRandomProvider
impl RandomProvider for TokioRandomProvider
Source§fn random<T>(&self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&self) -> Twhere
StandardUniform: Distribution<T>,
Generate a random value of type T. Read more
Source§fn random_range<T>(&self, range: Range<T>) -> Twhere
T: SampleUniform + PartialOrd,
fn random_range<T>(&self, range: Range<T>) -> Twhere
T: SampleUniform + PartialOrd,
Generate a random value within a specified range. Read more
Source§fn random_ratio(&self) -> f64
fn random_ratio(&self) -> f64
Generate a random f64 between 0.0 and 1.0. Read more
Auto Trait Implementations§
impl Freeze for TokioRandomProvider
impl RefUnwindSafe for TokioRandomProvider
impl Send for TokioRandomProvider
impl Sync for TokioRandomProvider
impl Unpin for TokioRandomProvider
impl UnwindSafe for TokioRandomProvider
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