Skip to main content

ReplayRunner

Struct ReplayRunner 

Source
pub struct ReplayRunner<S, F>
where F: Fn(u64, u64) -> (S, SimTrace),
{ /* private fields */ }
Expand description

A generic replay runner parameterized on user state type S.

The user provides a sim_fn that takes (seed, target_tick) and returns (state, trace). The replay runner uses this to implement time-travel debugging primitives.

use vortex_trace::replay::ReplayRunner;
use vortex_trace::SimTrace;

// Example: replay a simple counter simulation
let runner = ReplayRunner::new(42, |seed, ticks| {
    let mut trace = SimTrace::new();
    let mut counter = 0u64;
    for t in 0..ticks {
        counter += 1;
        // Record events to trace as needed
    }
    (counter, trace)
});

let (state, _trace) = runner.replay_to_tick(100);
assert_eq!(state, 100);

Implementations§

Source§

impl<S, F> ReplayRunner<S, F>
where F: Fn(u64, u64) -> (S, SimTrace),

Source

pub fn new(seed: u64, sim_fn: F) -> Self

Create a new replay runner.

  • seed: the deterministic seed for the simulation
  • sim_fn: (seed, target_tick) -> (state, trace)
Source

pub fn replay_to_tick(&self, target_tick: u64) -> (S, SimTrace)

Replay the simulation to a specific tick.

Creates a fresh simulation from the seed and runs to target_tick.

Source

pub fn replay_window( &self, start_tick: u64, end_tick: u64, ) -> (S, Vec<TraceEvent>)

Replay a window: run to end_tick, return events in [start_tick, end_tick].

Source

pub fn seed(&self) -> u64

The seed used by this runner.

Auto Trait Implementations§

§

impl<S, F> Freeze for ReplayRunner<S, F>
where F: Freeze,

§

impl<S, F> RefUnwindSafe for ReplayRunner<S, F>

§

impl<S, F> Send for ReplayRunner<S, F>
where F: Send, S: Send,

§

impl<S, F> Sync for ReplayRunner<S, F>
where F: Sync, S: Sync,

§

impl<S, F> Unpin for ReplayRunner<S, F>
where F: Unpin, S: Unpin,

§

impl<S, F> UnsafeUnpin for ReplayRunner<S, F>
where F: UnsafeUnpin,

§

impl<S, F> UnwindSafe for ReplayRunner<S, F>
where F: UnwindSafe, S: UnwindSafe,

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, 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.