Generator

Trait Generator 

Source
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§

Source

type Item: Clone + Send

The type of items this generator produces.

Source

type Config: Clone + Send + Sync

The configuration type for this generator.

Required Methods§

Source

fn new(config: Self::Config, seed: u64) -> Self
where Self: Sized,

Initialize the generator with configuration and seed.

The seed ensures deterministic, reproducible generation.

Source

fn generate_one(&mut self) -> Self::Item

Generate a single item.

Source

fn reset(&mut self)

Reset the generator to initial state (same seed).

After reset, the generator will produce the same sequence of items.

Source

fn count(&self) -> u64

Get the current generation count.

Source

fn seed(&self) -> u64

Get the seed used by this generator.

Provided Methods§

Source

fn generate_batch(&mut self, count: usize) -> Vec<Self::Item>

Generate a batch of items.

Default implementation calls generate_one repeatedly.

Source

fn generate_iter(&mut self, count: usize) -> GeneratorIterator<'_, Self>
where Self: Sized,

Generate items into an iterator.

Useful for lazy evaluation and streaming.

Implementors§