Skip to main content

MacroPlayer

Struct MacroPlayer 

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

Source

pub fn new(input_macro: &'a InputMacro) -> Self

Create a player for the given macro.

Source

pub fn position(&self) -> usize

Get current playback position (event index).

Source

pub fn elapsed(&self) -> Duration

Get elapsed virtual time.

Source

pub fn is_done(&self) -> bool

Check if playback is complete.

Source

pub fn remaining(&self) -> usize

Get the number of remaining events.

Source

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.

Source

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.

Source

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.

Source

pub fn replay_with_sleeper<M, F>( &mut self, sim: &mut ProgramSimulator<M>, sleep: F, )
where M: Model, F: FnMut(Duration),

Replay all remaining events with a custom sleep function.

Useful for tests that want to avoid real sleeping while still verifying the delay schedule.

Source

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.

Source

pub fn reset(&mut self)

Reset playback to the beginning.

Auto Trait Implementations§

§

impl<'a> Freeze for MacroPlayer<'a>

§

impl<'a> RefUnwindSafe for MacroPlayer<'a>

§

impl<'a> Send for MacroPlayer<'a>

§

impl<'a> Sync for MacroPlayer<'a>

§

impl<'a> Unpin for MacroPlayer<'a>

§

impl<'a> UnwindSafe for MacroPlayer<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more