Trait PureLogic

pub trait PureLogic<E, S>
where E: Event, S: State,
{ // Required methods fn handle( &mut self, event: &E, meta: &EventMeta, state: S, ) -> EventHandleResult<E, S>; fn compute_fields(&self, state: &mut S, prev_state: &S) -> Vec<E>; fn collect_due_scheduled(&mut self, current_tick: u64) -> Vec<E>; }
Expand description

Synchronous logic with no context of its own. Implement this once and Pure turns it into an EventHandler whose Context = (), which the synchronous System::run driver accepts — so tests and offline simulators run the shipping logic without a database.

The production handler keeps its own EventHandler impl over the same logic object: only persistence differs.

Required Methods§

fn handle( &mut self, event: &E, meta: &EventMeta, state: S, ) -> EventHandleResult<E, S>

Handle one event. meta is passed whole rather than pre-resolved into an RNG, because the stream an impl wants is its own choice — see Seed::rng for the usual one.

fn compute_fields(&self, state: &mut S, prev_state: &S) -> Vec<E>

fn collect_due_scheduled(&mut self, current_tick: u64) -> Vec<E>

Implementors§