aboutsummaryrefslogtreecommitdiff
path: root/src/messages/mod.rs
blob: ca74078b53e2374a48a80483d7d897bf5f58f250 (plain) (blame)
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
use std::marker::Sized;

pub mod callback;
pub mod not_understood;

pub use self::callback::Callback;
pub use self::not_understood::NotUnderstood;

#[derive(Serialize)]
pub struct OutgoingMsg<T> {
    pub result_type: String,
    pub content: T,
}

pub trait Message {
    fn name(&self) -> String;
    fn as_outgoing(self) -> OutgoingMsg<Self>
    where
        Self: Sized,
    {
        OutgoingMsg {
            result_type: self.name(),
            content: self,
        }
    }
}