# [−] [src] Module rand_core::block

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` (see `rand` crate) 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 [`RngCore`] for some type implementing [`BlockRngCore`] with `u32` array buffer; i.e. this can be used to implement a full RNG from just a `generate` function.
BlockRng64 | A wrapper type implementing [`RngCore`] for some type implementing [`BlockRngCore`] with `u64` array buffer; i.e. this can be used to implement a full RNG from just a `generate` function.

## Traits

BlockRngCore | A trait for RNGs which do not generate random numbers individually, but in blocks (typically `[u32; N]`). This technique is commonly used by cryptographic RNGs to improve performance.

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)