foundationdb::env

Trait Rng

Source
pub trait Rng:
    Debug
    + Send
    + Sync {
    // Required method
    fn next_u64(&self) -> u64;

    // Provided method
    fn next_u32(&self) -> u32 { ... }
}
Expand description

Where pseudo-random values come from.

See the module documentation for why randomness is a dependency rather than something to reach for, and for the pattern to follow when a lot of randomness is needed.

Implementations are not cryptographically secure and must not be used to derive secrets, tokens or keys.

Required Methods§

Source

fn next_u64(&self) -> u64

The next value of the sequence, uniform over the whole u64 range.

This takes &self so that a generator can be shared: an implementation advances its state through interior mutability.

Provided Methods§

Source

fn next_u32(&self) -> u32

The next value of the sequence, uniform over the whole u32 range.

The default implementation truncates next_u64.

Implementors§