Struct rand_core::impls::BlockRng
[−]
[src]
pub struct BlockRng<R: BlockRngCore + ?Sized> { /* fields omitted */ }
Wrapper around PRNGs that implement BlockRngCore
to keep a results
buffer and offer the methods from RngCore
.
BlockRng
has heavily optimized implementations of the RngCore
methods
reading values from the results buffer, as well as
calling BlockRngCore::generate
directly on the output array when
fill_bytes
/ try_fill_bytes
is called on a large array. These methods
also handle the bookkeeping of when to generate a new batch of values.
No generated values are ever thown away.
Currently BlockRng
only implements RngCore
for buffers which are slices
of u32
elements; this may be extended to other types in the future.
For easy initialization BlockRng
also implements SeedableRng
.
Methods
impl<R: BlockRngCore> BlockRng<R>
[src]
pub fn new(core: R) -> BlockRng<R>
[src]
Create a new BlockRng
from an existing RNG implementing
BlockRngCore
. Results will be generated on first use.
pub fn inner(&self) -> &R
[src]
Return a reference the wrapped BlockRngCore
.
pub fn inner_mut(&mut self) -> &mut R
[src]
Return a mutable reference the wrapped BlockRngCore
.
pub fn reset(&mut self)
[src]
Trait Implementations
impl<R: Clone + BlockRngCore + ?Sized> Clone for BlockRng<R> where
R::Results: Clone,
[src]
R::Results: Clone,
fn clone(&self) -> BlockRng<R>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<R: BlockRngCore + Debug> Debug for BlockRng<R>
[src]
fn fmt(&self, fmt: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<R: BlockRngCore<Item = u32>> RngCore for BlockRng<R> where
<R as BlockRngCore>::Results: AsRef<[u32]>,
[src]
<R as BlockRngCore>::Results: AsRef<[u32]>,
fn next_u32(&mut self) -> u32
[src]
Return the next random u32
. Read more
fn next_u64(&mut self) -> u64
[src]
Return the next random u64
. Read more
fn fill_bytes(&mut self, dest: &mut [u8])
[src]
Fill dest
with random data. Read more
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>
[src]
Fill dest
entirely with random data. Read more
impl<R: BlockRngCore + SeedableRng> SeedableRng for BlockRng<R>
[src]
type Seed = R::Seed
Seed type, which is restricted to types mutably-dereferencable as u8
arrays (we recommend [u8; N]
for some N
). Read more
fn from_seed(seed: Self::Seed) -> Self
[src]
Create a new PRNG using the given seed. Read more
fn from_rng<S: RngCore>(rng: S) -> Result<Self, Error>
[src]
Create a new PRNG seeded from another Rng
. Read more