Skip to main content

PersistenceModel

Trait PersistenceModel 

Source
pub trait PersistenceModel {
    type PState: Clone;
    type Delta: Clone;

    // Required methods
    fn apply(
        state: &mut Self::PState,
        delta: &Self::Delta,
    ) -> Result<(), String>;
    fn derive(
        before: &Self::PState,
        after: &Self::PState,
    ) -> Result<Self::Delta, String>;
    fn open_delta(session: SessionId) -> Self::Delta;
    fn close_delta(session: SessionId) -> Self::Delta;

    // Provided method
    fn invoke_delta(_session: SessionId, _action: &str) -> Option<Self::Delta> { ... }
}
Expand description

Persistence-model contract.

Required Associated Types§

Source

type PState: Clone

Persistent state representation.

Source

type Delta: Clone

Delta representation for incremental updates.

Required Methods§

Source

fn apply(state: &mut Self::PState, delta: &Self::Delta) -> Result<(), String>

Apply one delta to state.

§Errors

Returns an error if the delta cannot be applied.

Source

fn derive( before: &Self::PState, after: &Self::PState, ) -> Result<Self::Delta, String>

Derive a delta between two states.

§Errors

Returns an error if derivation fails.

Source

fn open_delta(session: SessionId) -> Self::Delta

Open-session lifecycle delta.

Source

fn close_delta(session: SessionId) -> Self::Delta

Close-session lifecycle delta.

Provided Methods§

Source

fn invoke_delta(_session: SessionId, _action: &str) -> Option<Self::Delta>

Optional invoke-action delta.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§