Skip to content

Commit 0eefffb

Browse files
committed
Add BlockRngCore trait
1 parent 11c6178 commit 0eefffb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,15 @@ impl<R: SeedableRng> NewRng for R {
10021002
}
10031003
}
10041004

1005+
/// Trait for RNG's that do not generate random numbers one at a time, but in
1006+
/// blocks. Especially for cryptographic RNG's it is common to generate 16 or
1007+
/// more results at a time.
1008+
pub trait BlockRngCore<T>: Sized {
1009+
type Results: AsRef<[T]> + Default;
1010+
1011+
fn generate(&mut self, results: &mut Self::Results) -> Result<(), Error>;
1012+
}
1013+
10051014
/// The standard RNG. The PRNG algorithm in `StdRng` is choosen to be efficient
10061015
/// on the current platform, to be statistically strong and unpredictable
10071016
/// (meaning a cryptographically secure PRNG).

0 commit comments

Comments
 (0)