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
use actix::prelude::*;

use std::any::TypeId;

pub trait BrokerMsg: Message<Result = ()> + Send + Clone + 'static {}

impl<M> BrokerMsg for M where M: Message<Result = ()> + Send + Clone + 'static {}

#[derive(Message)]
#[rtype(result = "()")]
pub struct SubscribeAsync<M: BrokerMsg>(pub Recipient<M>, pub TypeId);

pub struct SubscribeSync<M: BrokerMsg>(pub Recipient<M>, pub TypeId);

impl<M: BrokerMsg> Message for SubscribeSync<M> {
    type Result = Option<M>;
}

#[derive(Message)]
#[rtype(result = "()")]
pub struct IssueAsync<M: BrokerMsg>(pub M, pub TypeId);

#[derive(Message)]
#[rtype(result = "()")]
pub struct IssueSync<M: BrokerMsg>(pub M, pub TypeId);