pub trait Generator {
type Item: Clone + Send;
type Config: Clone + Send + Sync;
// Required methods
fn new(config: Self::Config, seed: u64) -> Self
where Self: Sized;
fn generate_one(&mut self) -> Self::Item;
fn reset(&mut self);
fn count(&self) -> u64;
fn seed(&self) -> u64;
// Provided methods
fn generate_batch(&mut self, count: usize) -> Vec<Self::Item> { ... }
fn generate_iter(&mut self, count: usize) -> GeneratorIterator<'_, Self> ⓘ
where Self: Sized { ... }
}Expand description
Core trait for all data generators.
Generators produce synthetic data items based on configuration and statistical distributions. They support deterministic generation via seeding for reproducibility.
Required Associated Types§
Required Methods§
Sourcefn new(config: Self::Config, seed: u64) -> Selfwhere
Self: Sized,
fn new(config: Self::Config, seed: u64) -> Selfwhere
Self: Sized,
Initialize the generator with configuration and seed.
The seed ensures deterministic, reproducible generation.
Sourcefn generate_one(&mut self) -> Self::Item
fn generate_one(&mut self) -> Self::Item
Generate a single item.
Provided Methods§
Sourcefn generate_batch(&mut self, count: usize) -> Vec<Self::Item>
fn generate_batch(&mut self, count: usize) -> Vec<Self::Item>
Generate a batch of items.
Default implementation calls generate_one repeatedly.
Sourcefn generate_iter(&mut self, count: usize) -> GeneratorIterator<'_, Self> ⓘwhere
Self: Sized,
fn generate_iter(&mut self, count: usize) -> GeneratorIterator<'_, Self> ⓘwhere
Self: Sized,
Generate items into an iterator.
Useful for lazy evaluation and streaming.