Skip to main content

DataSource

Trait DataSource 

Source
pub trait DataSource: Debug {
    type Seed: Clone;

    // Required methods
    fn initialize(seed: Self::Seed) -> Self;
    fn reinitialize(&mut self) -> Self::Seed;
    fn next_u64(&mut self) -> u64;
}
Expand description

A DataSource is an oracle for generating non-deterministic data to return to a task that asks for random values.

Required Associated Types§

Source

type Seed: Clone

A Seed can be used to deterministically initialize a data source such that it produces the same sequence of outputs for next_u64 calls.

Required Methods§

Source

fn initialize(seed: Self::Seed) -> Self

Initialize the DataSource from a given seed.

Source

fn reinitialize(&mut self) -> Self::Seed

Reinitialize the DataSource and return a seed that can be used to return to this state for deterministic replay.

Source

fn next_u64(&mut self) -> u64

Generate the next non-deterministic u64 value to return to a requesting task.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§