Module rngs

Random number generators and adapters

Generators

This crate provides a small selection of generators. See also Types of generators and Our RNGs in the book.

Non-deterministic generators
Standard generators

These use selected best-in-class algorithms. They are deterministic but not portable: the algorithms may be changed in any release and may be platform-dependent.

Named portable generators

These are similar to the standard generators, but with the additional guarantees of reproducibility:

Additional generators

For more, search crates with the rng tag.

Traits and functionality

All generators implement TryRng. Most implement Rng (i.e. TryRng<Error = Infallible>) and thus also implement RngExt. See also the Random Values chapter in the book.

Secure RNGs may additionally implement the CryptoRng trait.

Use the rand_core crate when implementing your own RNGs.

  1. D. J. Bernstein, ChaCha, a variant of Salsa20

Structs