Expand description
ReseedingRng that periodically reseeds the underlying pseudorandom number
generator.
This crate provides a simplified reimplementation of ReseedingRng for use with
the random number generators from the rand crate v0.10, which no longer
includes the ReseedingRng from v0.9 and earlier.
Note that periodic reseeding is never strictly necessary.
See the rand v0.9 documentation for further discussion.
This crate is no_std-compatible.
§Examples
ReseedingRng is useful to replicate the reseeding behavior of ThreadRng.
As of rand v0.10.0, ThreadRng uses the same algorithm as StdRng and
reseeds it via SysRng every 64KiB of output. You can emulate this behavior
by configuring ReseedingRng as follows:
use rand::{RngExt as _, rngs::StdRng, rngs::SysRng};
use reseeding_rng::ReseedingRng;
let mut rng = ReseedingRng::<StdRng, _>::try_new(1024 * 64, SysRng)
.expect("couldn't initialize ReseedingRng due to SysRng failure");
println!("{:?}", rng.random::<[char; 4]>());Structs§
- Reseeding
Rng - A wrapper that periodically reseeds the underlying pseudorandom number generator.