Trait Command

Source
pub trait Command<E: Event> {
    type State: AggregateState<E>;
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn handle(&self) -> Result<Vec<E>, Self::Error>;
    fn event_stream_id(&self) -> EventStreamId;
    fn get_state(&self) -> Self::State;
    fn set_state(&self, state: Self::State) -> Self;

    // Provided methods
    fn mark_retry(&self) -> Self
       where Self: Sized + Clone { ... }
    fn override_expected_version(&self) -> Option<EventStreamVersion> { ... }
    fn apply(&mut self, event: E) -> Self
       where Self: Sized { ... }
}

Required Associated Types§

Source

type State: AggregateState<E>

Source

type Error: Error + Send + Sync + 'static

Required Methods§

Source

fn handle(&self) -> Result<Vec<E>, Self::Error>

Source

fn event_stream_id(&self) -> EventStreamId

Source

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

Source

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

Provided Methods§

Source

fn mark_retry(&self) -> Self
where Self: Sized + Clone,

Source

fn override_expected_version(&self) -> Option<EventStreamVersion>

Source

fn apply(&mut self, event: E) -> Self
where Self: Sized,

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.

Implementations on Foreign Types§

Source§

impl<E: Event> Command<E> for ()

Source§

type State = ()

Source§

type Error = Infallible

Source§

fn handle(&self) -> Result<Vec<E>, Self::Error>

Source§

fn event_stream_id(&self) -> EventStreamId

Source§

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

Source§

fn set_state(&self, _: Self::State) -> Self

Source§

fn mark_retry(&self) -> Self

Implementors§