blob: 52f2d6f7640c641e263e5bebcb3e2e27266fe38f (
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
|
use std::marker::Sized;
pub mod callback;
pub mod not_understood;
pub use self::callback::Callback;
pub use self::not_understood::NotUnderstood;
use serde_derive::{Deserialize, Serialize};
#[derive(Deserialize, 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,
}
}
}
|