1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use async_trait::async_trait;
use std::{fmt::Debug, sync::mpsc::TryRecvError};
#[async_trait]
pub trait AsyncMediatorInternal<Ev: Debug> {
async fn publish(&self, event: Ev);
}
#[async_trait]
pub trait AsyncMediatorInternalHandle<Ev: Debug> {
async fn send<Req>(&self, req: Req)
where
Req: Send,
Self: AsyncRequestHandler<Req, Ev>;
}
#[async_trait]
pub trait AsyncMediatorInternalNext {
async fn next(&self) -> Result<(), TryRecvError>;
}
#[async_trait]
pub trait AsyncRequestHandler<Req, Res>
where
Self: Sync,
{
async fn handle(&self, req: Req);
}