framework-cqrs-lib 0.4.0

handle state-machine with data persist in journal and store mongo for restfull actix api
Documentation
use async_trait::async_trait;

use crate::cqrs::core::data::EntityEvent;
use crate::cqrs::core::repositories::can_fetch_all::CanFetchAll;
use crate::cqrs::core::repositories::CanFetchMany;
use crate::cqrs::models::errors::ResultErr;

#[async_trait]
pub trait RepositoryEvents<DATA: Clone, ID: Clone>: ReadOnlyEventRepo<DATA, ID> + WriteOnlyEventRepo<DATA, ID> {}

#[async_trait]
pub trait ReadOnlyEventRepo<DATA: Clone, ID: Clone>: CanFetchAll<EntityEvent<DATA, ID>> + CanFetchMany<EntityEvent<DATA, ID>> + Sync + Send {
    async fn fetch_one(&self, id: &ID) -> ResultErr<Option<EntityEvent<DATA, ID>>>;
}

#[async_trait]
pub trait WriteOnlyEventRepo<DATA, ID> {
    async fn insert(&self, entity: &EntityEvent<DATA, ID>) -> ResultErr<ID>;
}