pub struct DetRng { /* private fields */ }Expand description
A deterministic pseudo-random number generator.
Uses a 64-bit LCG (Linear Congruential Generator) with PCG constants. Same seed always produces the same sequence — this is the foundation of Vortex’s reproducibility guarantee.
Implementations§
Source§impl DetRng
impl DetRng
Sourcepub fn derive(master_seed: u64, domain: &str) -> Self
pub fn derive(master_seed: u64, domain: &str) -> Self
Create a child RNG for a subsystem by mixing the master seed with a domain tag.
This ensures different subsystems (network, storage, clock) get independent but deterministic random streams from the same master seed.
let master = 42u64;
let net_rng = DetRng::derive(master, "network");
let disk_rng = DetRng::derive(master, "storage");
// net_rng and disk_rng produce different sequencesSourcepub fn next_u64_below(&mut self, max: u64) -> u64
pub fn next_u64_below(&mut self, max: u64) -> u64
Return a random u64 in [0, max) (exclusive upper bound).
Sourcepub fn next_u64_range(&mut self, min: u64, max: u64) -> u64
pub fn next_u64_range(&mut self, min: u64, max: u64) -> u64
Return a random u64 in [min, max] (inclusive both bounds).
Auto Trait Implementations§
impl Freeze for DetRng
impl RefUnwindSafe for DetRng
impl Send for DetRng
impl Sync for DetRng
impl Unpin for DetRng
impl UnsafeUnpin for DetRng
impl UnwindSafe for DetRng
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