mediator_sys/mediator/asynchronous/contextaware/
interface.rs

1use async_trait::async_trait;
2use std::fmt::Debug;
3
4/// Send a request `Req` asynchronously for processing to the mediator.
5/// This will call the handler.
6/// The handler here is context-dependent.
7#[async_trait]
8pub trait CxAwareAsyncMediatorInternalHandle<Dep, Ev: Debug> {
9    async fn send<Req>(&self, req: Req)
10    where
11        Req: Send,
12        Self: CxAwareAsyncRequestHandler<Dep, Req, Ev>;
13}
14
15/// Handles the request `Req` asynchronously.
16/// Implemented by the user.
17/// Gives access to the dependency `Dep`.
18#[async_trait]
19pub trait CxAwareAsyncRequestHandler<Dep, Req, Res> {
20    async fn handle(&self, req: Req, dep: &Dep);
21}
22
23/// Advanced builder fuctionality:
24/// Adding a dependency `dep` to the builder.
25pub trait CxAwareMediatorBuilderInterface<M, Dep, Ev> {
26    fn add_dependency(self, dep: Dep) -> Self
27    where
28        Ev: Debug;
29}