pub struct MacroPlayer<'a> { /* private fields */ }Expand description
Replays an InputMacro through a [ProgramSimulator].
Events are injected in order. Timing information is available for inspection but does not cause real delays (the simulator is deterministic and instant).
Implementations§
Source§impl<'a> MacroPlayer<'a>
impl<'a> MacroPlayer<'a>
Sourcepub fn new(input_macro: &'a InputMacro) -> Self
pub fn new(input_macro: &'a InputMacro) -> Self
Create a player for the given macro.
Sourcepub fn step<M: Model>(&mut self, sim: &mut ProgramSimulator<M>) -> bool
pub fn step<M: Model>(&mut self, sim: &mut ProgramSimulator<M>) -> bool
Step one event, injecting it into the simulator.
Returns true if an event was played, false if playback is complete.
Sourcepub fn replay_all<M: Model>(&mut self, sim: &mut ProgramSimulator<M>)
pub fn replay_all<M: Model>(&mut self, sim: &mut ProgramSimulator<M>)
Replay all remaining events into the simulator.
Stops early if the simulator quits.
Sourcepub fn replay_with_timing<M: Model>(&mut self, sim: &mut ProgramSimulator<M>)
pub fn replay_with_timing<M: Model>(&mut self, sim: &mut ProgramSimulator<M>)
Replay all remaining events, honoring recorded delays.
This uses real wall-clock sleeping for each recorded delay before injecting the event. Stops early if the simulator quits.
Sourcepub fn replay_with_sleeper<M, F>(
&mut self,
sim: &mut ProgramSimulator<M>,
sleep: F,
)
pub fn replay_with_sleeper<M, F>( &mut self, sim: &mut ProgramSimulator<M>, sleep: F, )
Replay all remaining events with a custom sleep function.
Useful for tests that want to avoid real sleeping while still verifying the delay schedule.
Sourcepub fn replay_until<M: Model>(
&mut self,
sim: &mut ProgramSimulator<M>,
until: Duration,
)
pub fn replay_until<M: Model>( &mut self, sim: &mut ProgramSimulator<M>, until: Duration, )
Replay events up to the given virtual time.
Only events whose cumulative delay is within until are played.