1use futures::never::Never;
2use mm1_common::types::AnyError;
3
4pub enum Outcome<Rs = Never> {
5 Reply(Rs),
6 NoReply,
7 Break,
8}
9
10pub trait OnMessage<Ctx, M>: Send {
11 fn on_message(
12 &mut self,
13 ctx: &mut Ctx,
14 message: M,
15 ) -> impl Future<Output = Result<Outcome, AnyError>> + Send;
16}
17
18pub trait OnRequest<Ctx, Rq>: Send {
19 type Rs;
20
21 fn on_request(
22 &mut self,
23 ctx: &mut Ctx,
24 request: Rq,
25 ) -> impl Future<Output = Result<Outcome<Self::Rs>, AnyError>> + Send;
26}