use crate::request::Request;
use crate::Event;
#[cfg(feature = "streams")]
use crate::StreamRequest;
#[cfg(feature = "streams")]
use crate::futures::Stream;
pub trait Mediator {
fn send<Req, Res>(&mut self, req: Req) -> crate::Result<Res>
where
Res: 'static,
Req: Request<Res> + 'static;
fn publish<E>(&mut self, event: E) -> crate::Result<()>
where
E: Event + 'static;
#[cfg(feature = "streams")]
fn stream<Req, S, T>(&mut self, req: Req) -> crate::Result<S>
where
Req: StreamRequest<Stream = S, Item = T> + 'static,
S: Stream<Item = T> + 'static,
T: 'static;
}
#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
pub trait AsyncMediator {
async fn send<Req, Res>(&mut self, req: Req) -> crate::Result<Res>
where
Res: Send + 'static,
Req: Request<Res> + Send + 'static;
async fn publish<E>(&mut self, event: E) -> crate::Result<()>
where
E: Event + Sync + Send + 'static;
#[cfg(feature = "streams")]
async fn stream<Req, S, T>(&mut self, req: Req) -> crate::Result<S>
where
Req: StreamRequest<Stream = S, Item = T> + Send + 'static,
S: Stream<Item = T> + Send + 'static,
T: Send + 'static;
}