Skip to main content

TrafficSource

Trait TrafficSource 

Source
pub trait TrafficSource {
    // Required method
    fn generate(&mut self, tick: u64) -> Vec<SpawnRequest>;
}
Expand description

Trait for external traffic generators.

Implementors produce zero or more SpawnRequests per tick. The consumer is responsible for feeding them into the simulation:

for req in source.generate(tick) {
    sim.spawn_rider_by_stop_id(req.origin, req.destination, req.weight)?;
}

This design keeps traffic generation external to the simulation loop, giving consumers full control over when and how riders are spawned.

Required Methods§

Source

fn generate(&mut self, tick: u64) -> Vec<SpawnRequest>

Generate spawn requests for the given tick.

May return an empty vec (no arrivals this tick) or multiple requests (burst arrivals). The implementation controls the arrival process.

Implementors§