aboutsummaryrefslogtreecommitdiff
path: root/src/routes/messages.rs
diff options
context:
space:
mode:
authorKevin J Hoerr <kjhoerr@protonmail.com>2018-08-31 19:47:09 -0400
committerKevin Hoerr <kjhoerr@submelon.tech>2018-08-31 23:24:45 -0400
commit4fb3dc1c9d6b74df77a4d56d826b8842481bb377 (patch)
tree729f93aa88f40f74bdce8414ab77209dc3b911b6 /src/routes/messages.rs
parent8ec18f34412e691356bf431b3d81ca08937a9c36 (diff)
downloadaugust-offensive-4fb3dc1c9d6b74df77a4d56d826b8842481bb377.tar.gz
august-offensive-4fb3dc1c9d6b74df77a4d56d826b8842481bb377.tar.bz2
august-offensive-4fb3dc1c9d6b74df77a4d56d826b8842481bb377.zip
Implement NotUnderstood message; Wrap messages with OutgoingMsg
Diffstat (limited to 'src/routes/messages.rs')
-rw-r--r--src/routes/messages.rs33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/routes/messages.rs b/src/routes/messages.rs
index c4f2b5e..7b7a70b 100644
--- a/src/routes/messages.rs
+++ b/src/routes/messages.rs
@@ -1,15 +1,29 @@
-use std::collections::HashMap;
+use std::{collections::HashMap, marker::Sized};
-trait Content {}
+#[derive(Serialize)]
+pub struct OutgoingMsg<T> {
+ pub result_type: String,
+ pub content: T,
+}
-trait Message {
+pub trait Message {
fn name(&self) -> String;
+ fn as_outgoing(self) -> OutgoingMsg<Self>
+ where
+ Self: Sized,
+ {
+ OutgoingMsg {
+ result_type: self.name(),
+ content: self,
+ }
+ }
}
#[derive(Serialize)]
pub struct Callback {
pub path: Vec<String>,
- pub request: HashMap<String, String>,
+ pub request: String,
+ pub content: HashMap<String, String>,
}
impl Message for Callback {
@@ -17,3 +31,14 @@ impl Message for Callback {
String::from("CALLBACK")
}
}
+
+#[derive(Serialize)]
+pub struct NotUnderstood {
+ pub path: Vec<String>,
+}
+
+impl Message for NotUnderstood {
+ fn name(&self) -> String {
+ String::from("NOT_UNDERSTOOD")
+ }
+}