Module rand_core::block [−][src]
The BlockRngCore
trait and implementation helpers
The BlockRngCore
trait exists to assist in the implementation of RNGs
which generate a block of data in a cache instead of returning generated
values directly.
Usage of this trait is optional, but provides two advantages:
implementations only need to concern themselves with generation of the
block, not the various RngCore
methods (especially fill_bytes
, where
the optimal implementations are not trivial), and this allows
ReseedingRng
perform periodic reseeding with very low overhead.
Example
use rand_core::block::{BlockRngCore, BlockRng};
struct MyRngCore;
impl BlockRngCore for MyRngCore {
type Results = [u32; 16];
fn generate(&mut self, results: &mut Self::Results) {
unimplemented!()
}
}
impl SeedableRng for MyRngCore {
type Seed = unimplemented!();
fn from_seed(seed: Self::Seed) -> Self {
unimplemented!()
}
}
// optionally, also implement CryptoRng for MyRngCore
// Final RNG.
type MyRng = BlockRng<u32, MyRngCore>;
Structs
BlockRng |
A wrapper type implementing |
BlockRng64 |
A wrapper type implementing |
Traits
BlockRngCore |
A trait for RNGs which do not generate random numbers individually, but in
blocks (typically |