artichoke_backend::prelude

Trait Prng

Source
pub trait Prng {
    type Error;
    type Prng;

    // Required methods
    fn prng(&self) -> Result<&Self::Prng, Self::Error>;
    fn prng_mut(&mut self) -> Result<&mut Self::Prng, Self::Error>;
}
Expand description

Interpreter global pseudorandom number generator (PRNG).

Implementations of this trait may be used as the backing pseudorandom number generator for Random::DEFAULT.

The PRNG used to implement this trait is not required to be cryptographically secure. For example, MRI’s PRNG is a variant of Mersenne Twister.

Required Associated Types§

Source

type Error

Concrete type for errors when retrieving the pseudorandom number generator.

Source

type Prng

Concrete type for the interpreter pseudorandom number generator.

Required Methods§

Source

fn prng(&self) -> Result<&Self::Prng, Self::Error>

Return a shared reference to the interpreter pseudorandom number generator.

§Errors

If the PRNG is inaccessible, an error is returned.

Source

fn prng_mut(&mut self) -> Result<&mut Self::Prng, Self::Error>

Return a mutable reference to the interpreter pseudorandom number generator.

§Errors

If the PRNG is inaccessible, an error is returned.

Implementors§

Source§

impl Prng for Artichoke

Available on crate feature core-random only.