Crate rand_core [] [src]

Random number generation traits

This crate is mainly of interest to crates publishing implementations of Rng. Other users are encouraged to use the rand crate instead.

Rng is the core trait implemented by algorithmic pseudo-random number generators and external random-number sources.

SeedFromRng and SeedableRng are extension traits for construction and reseeding.

Error and Result are provided for error-handling. They are safe to use in no_std environments.

The impls sub-module includes a few small functions to assist implementation of Rng. Since this module is only of interest to Rng implementors, it is not re-exported from rand.

The mock module includes a mock Rng implementation. Even though this is only useful for testing, it is currently always built.

Modules

impls

Helper functions for implementing Rng functions.

mock

Mock RNG implementations

Structs

Error

Error type for cryptographic generators. Technically external generators such as the operating system or hardware generators could fail. A PRNG (algorithm) could also fail if it detects cycles, though most PRNGs have sufficiently long cycles that looping is not usually feasible.

Traits

Rng

A random number generator.

SeedFromRng

Support mechanism for creating random number generators seeded by other generators. All PRNGs should support this to enable NewSeeded support, which should be the preferred way of creating randomly-seeded generators.

SeedableRng

A random number generator that can be explicitly seeded to produce the same stream of randomness multiple times.

Type Definitions

Result

Result type (convenience type-def)