aboutsummaryrefslogtreecommitdiff
path: root/src/routes/messages.rs
diff options
context:
space:
mode:
authorKevin J Hoerr <kjhoerr@protonmail.com>2019-10-29 00:21:26 -0400
committerKevin J Hoerr <kjhoerr@protonmail.com>2019-10-29 00:21:26 -0400
commit067e9784b54e4645412e5e7d8d7d2bc70bdcf646 (patch)
tree08dfd1a323a88f5db41eb25b568fc9b9b88b0b03 /src/routes/messages.rs
parent7fa4d1973e6f82551d842919e54629b9a7ab08f0 (diff)
downloadaugust-offensive-067e9784b54e4645412e5e7d8d7d2bc70bdcf646.tar.gz
august-offensive-067e9784b54e4645412e5e7d8d7d2bc70bdcf646.tar.bz2
august-offensive-067e9784b54e4645412e5e7d8d7d2bc70bdcf646.zip
Split messages into separate module; add unit tests for each message type
Diffstat (limited to 'src/routes/messages.rs')
-rw-r--r--src/routes/messages.rs44
1 files changed, 0 insertions, 44 deletions
diff --git a/src/routes/messages.rs b/src/routes/messages.rs
deleted file mode 100644
index 7b7a70b..0000000
--- a/src/routes/messages.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-use std::{collections::HashMap, marker::Sized};
-
-#[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,
- }
- }
-}
-
-#[derive(Serialize)]
-pub struct Callback {
- pub path: Vec<String>,
- pub request: String,
- pub content: HashMap<String, String>,
-}
-
-impl Message for Callback {
- fn name(&self) -> String {
- String::from("CALLBACK")
- }
-}
-
-#[derive(Serialize)]
-pub struct NotUnderstood {
- pub path: Vec<String>,
-}
-
-impl Message for NotUnderstood {
- fn name(&self) -> String {
- String::from("NOT_UNDERSTOOD")
- }
-}