Struct rand_core::impls::BlockRng [] [src]

pub struct BlockRng<R: BlockRngCore + ?Sized> {
    pub results: R::Results,
    pub index: usize,
    pub core: R,
}

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.

Fields

Trait Implementations

impl<R: Clone + BlockRngCore + ?Sized> Clone for BlockRng<R> where
    R::Results: Clone
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<R: BlockRngCore + Debug> Debug for BlockRng<R>
[src]

[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]

[src]

Return the next random u32. Read more

[src]

Return the next random u64. Read more

[src]

Fill dest with random data. Read more

[src]

Fill dest entirely with random data. Read more

impl<R: BlockRngCore + SeedableRng> SeedableRng for BlockRng<R>
[src]

Seed type, which is restricted to types mutably-dereferencable as u8 arrays (we recommend [u8; N] for some N). Read more

[src]

Create a new PRNG using the given seed. Read more

[src]

Create a new PRNG seeded from another Rng. Read more

impl<R: BlockRngCore + CryptoRng> CryptoRng for BlockRng<R>
[src]

Auto Trait Implementations

impl<R: ?Sized> Send for BlockRng<R> where
    R: Send,
    <R as BlockRngCore>::Results: Send

impl<R: ?Sized> Sync for BlockRng<R> where
    R: Sync,
    <R as BlockRngCore>::Results: Sync