aboutsummaryrefslogtreecommitdiff
path: root/src/messages/mod.rs
blob: 18f2bb788cf9b390894229b08383a61313588251 (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
27
28
use std::marker::Sized;

pub mod format_msg;
pub mod callback;
pub mod not_understood;

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

#[derive(Serialize)]
pub struct OutgoingMsg<T: Message> {
    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,
        }
    }
}