cqrs-rust-lib 0.8.0

An opinionated implementation of CQRS/Event Sourcing with pluggable storage backends (InMemory, PostgreSQL, MongoDB, SurrealDB)
Documentation
use crate::{Aggregate, CqrsContext, CqrsError, EventEnvelope, MaybeSend, MaybeSync};
use serde::de::DeserializeOwned;
use serde::Serialize;
use std::fmt::Debug;

cqrs_async_trait! {
pub trait Dispatcher<A: Aggregate>: MaybeSend + MaybeSync {
    async fn dispatch(
        &self,
        aggregate_id: &str,
        events: &[EventEnvelope<A>],
        context: &CqrsContext,
    ) -> Result<(), CqrsError>;
}
}

pub trait View<A: Aggregate>:
    Debug + Clone + Default + Serialize + DeserializeOwned + MaybeSend + MaybeSync
{
    const TYPE: &'static str;
    const IS_CHILD_OF_AGGREGATE: bool;

    fn view_id(event: &EventEnvelope<A>) -> String;
    fn update(&self, event: &EventEnvelope<A>) -> Option<Self>;
}

pub trait ViewElements<A: Aggregate>: View<A> {
    fn aggregate_id(&self) -> String;
}