shuttle_engine/scheduler/data/mod.rs
1use std::fmt::Debug;
2
3pub mod fixed;
4pub mod random;
5pub use random::RandomDataSource;
6
7/// A `DataSource` is an oracle for generating non-deterministic data to return to a task that asks
8/// for random values.
9pub trait DataSource: Debug {
10 /// A `Seed` can be used to deterministically initialize a data source such that it produces the
11 /// same sequence of outputs for `next_u64` calls.
12 type Seed: Clone;
13
14 /// Initialize the `DataSource` from a given seed.
15 fn initialize(seed: Self::Seed) -> Self;
16
17 /// Reinitialize the `DataSource` and return a seed that can be used to return to this state
18 /// for deterministic replay.
19 fn reinitialize(&mut self) -> Self::Seed;
20
21 /// Generate the next non-deterministic `u64` value to return to a requesting task.
22 fn next_u64(&mut self) -> u64;
23}