Skip to main content

StateRepository

Trait StateRepository 

Source
pub trait StateRepository<C, S, Version, Error> {
    // Required methods
    fn fetch_state(
        &self,
        command: &C,
    ) -> impl Future<Output = Result<Option<(S, Version)>, Error>> + Send;
    fn save(
        &self,
        state: &S,
        version: &Option<Version>,
    ) -> impl Future<Output = Result<(S, Version), Error>> + Send;
}
Expand description

State Repository trait

Generic parameters:

  • C - Command
  • S - State
  • Version - Version
  • Error - Error

Required Methods§

Source

fn fetch_state( &self, command: &C, ) -> impl Future<Output = Result<Option<(S, Version)>, Error>> + Send

Fetches current state, based on the command. Desugared async fn fetch_state(&self, command: &C) -> Result<Option<(S, Version)>, Error>; to a normal fn that returns impl Future and adds bound Send You can freely move between the async fn and -> impl Future spelling in your traits and impls. This is true even when one form has a Send bound.

Source

fn save( &self, state: &S, version: &Option<Version>, ) -> impl Future<Output = Result<(S, Version), Error>> + Send

Saves state. Desugared async fn save(&self, state: &S, version: &Option<Version>) -> Result<(S, Version), Error>; to a normal fn that returns impl Future and adds bound Send You can freely move between the async fn and -> impl Future spelling in your traits and impls. This is true even when one form has a Send bound.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<C, S, E, Repository, Decider, Version, Error> StateRepository<C, S, Version, Error> for StateStoredAggregate<C, S, E, Repository, Decider, Version, Error>
where Repository: StateRepository<C, S, Version, Error> + Sync, Decider: StateComputation<C, S, E, Error> + Sync, C: Sync, S: Sync, E: Sync, Version: Sync, Error: Sync,

Available on non-crate feature not-send-futures only.
Source§

impl<C, S, E, Repository, Version, Error> StateRepository<C, S, Version, Error> for StateStoredOrchestratingAggregate<'_, C, S, E, Repository, Version, Error>
where Repository: StateRepository<C, S, Version, Error> + Sync, C: Sync, S: Sync, E: Sync, Version: Sync, Error: Sync,

Available on non-crate feature not-send-futures only.