Skip to main content

Projection

Trait Projection 

Source
pub trait Projection {
    type Body: Body;
    type State;

    // Required methods
    fn apply(&mut self, event: &Event<Self::Body>);
    fn cursor(&self) -> u64;
    fn state(&self) -> &Self::State;
}
Expand description

A deterministic fold of the log into derived state. Rebuild, time-travel, and fork are all the same fold stopped at a different point (INV-1).

Required Associated Types§

Source

type Body: Body

The payload type this projection folds. Ties the projection to a Salamander<B> with the same B: you can only build a projection from a log whose events carry the payload it knows how to apply. Expressed as an associated type (not a trait parameter) so the generic replay helpers below read as P: Projection with no extra B to thread through.

Source

type State

The derived state this projection maintains.

Required Methods§

Source

fn apply(&mut self, event: &Event<Self::Body>)

Apply one event. MUST be deterministic and infallible on valid input: same events in same order => same state, every time, on every machine (DESIGN.md §6, INV-1).

Source

fn cursor(&self) -> u64

Current cursor: all events with offset < cursor have been applied.

Source

fn state(&self) -> &Self::State

Read access to derived state.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§