Skip to main content

ReplayHarness

Struct ReplayHarness 

Source
pub struct ReplayHarness;
Expand description

Drives an Eventsourced aggregate through a recorded entry stream, restoring RNG state first so derived computation is bit-identical to the original run.

§Replay contract

For each recorded PersistentRepr in sequence order:

  • ExternalCommand entries are decoded and applied as recorded — they represent inputs the aggregate cannot reproduce on its own.
  • DerivedEvent entries (and untagged entries, treated as derived) are decoded, applied, and — when the caller routes the originating command back through command_to_events — compared byte-for-byte against the recording. Any mismatch flips ReplayReport::matched to false.

The harness is intentionally generic and minimal: state is rebuilt purely by apply_event, so two replays from the same seed + snapshot yield identical Eventsourced::State.

Implementations§

Source§

impl ReplayHarness

Source

pub fn replay<E, F, G>( rng_state: RngState, state: &mut E::State, recorded: &[PersistentRepr], decode: F, re_encode: G, ) -> ReplayReport
where E: Eventsourced, F: FnMut(&[u8]) -> Option<E::Event>, G: FnMut(&E::Event) -> Vec<u8>,

Replay recorded entries into state, restoring rng_state first.

decode turns a payload into an event; re_encode re-serializes a recomputed derived event so it can be compared against the recording. Returns a ReplayReport.

Auto Trait Implementations§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,