pub struct Schedule { /* private fields */ }Expand description
Actions to run at set ticks, in the order given.
A loop with no actions holds an empty schedule, and Self::run_due then returns after a single test.
Implementations§
Source§impl Schedule
impl Schedule
Sourcepub fn parse(
raw: &[String],
model_id: &str,
actions: &[ActionDescriptor],
) -> Result<Self, ScheduleError>
pub fn parse( raw: &[String], model_id: &str, actions: &[ActionDescriptor], ) -> Result<Self, ScheduleError>
Resolves each ID@TICK against actions, the actions of model model_id. Order is preserved, so two
entries at one tick run in the order given.
An entry splits at its last @, so an id can contain @.
§Errors
Returns ScheduleError for an entry that is not of the form ID@TICK, or refers to no action in actions.
Sourcepub fn from_entries(entries: Vec<Scheduled>) -> Self
pub fn from_entries(entries: Vec<Scheduled>) -> Self
Builds a schedule from resolved entries. Two entries due at one tick run in the order given.
Sourcepub fn next_due_after(&self, tick: u64) -> Option<u64>
pub fn next_due_after(&self, tick: u64) -> Option<u64>
Returns the earliest tick after tick at which any action is due.
Sourcepub fn due(&self, tick: u64) -> impl Iterator<Item = &Scheduled>
pub fn due(&self, tick: u64) -> impl Iterator<Item = &Scheduled>
Returns the actions due exactly at tick, in the order given.
Sourcepub fn fire_ticks(&self, start: u64, count: u64, fire: Fire) -> Vec<u64>
pub fn fire_ticks(&self, start: u64, count: u64, fire: Fire) -> Vec<u64>
Returns the ticks at which a run of count steps from start fires under fire, in increasing
order and each once.
Fire::BeforeStep covers start..start + count and Fire::AfterStep covers
start + 1..=start + count. A run of no steps fires nothing under either rule.
Sourcepub fn run_due(&self, state: &mut dyn SimState) -> RefusedActions<'_>
pub fn run_due(&self, state: &mut dyn SimState) -> RefusedActions<'_>
Runs the actions due at the state’s current tick, and returns the entries that the state rejected.
A loop calls it either before each step and once at the end, or once at the start and after each step. Either way every tick from 0 to the tick where the run stops fires once.