nitinol_persistence/process.rs
1use async_trait::async_trait;
2use nitinol_core::event::Event;
3use nitinol_process::{Context, Process};
4
5#[async_trait]
6pub trait WithPersistence: 'static + Sync + Send
7where
8 Self: Process,
9{
10 async fn persist<E: Event>(&self, event: &E, ctx: &mut Context) {
11 crate::global::get_global_writer()
12 .write(self.aggregate_id(), event, ctx.sequence())
13 .await;
14 }
15}
16
17impl<T> WithPersistence for T where T: Process {}