diff options
Diffstat (limited to 'gateway')
| -rw-r--r-- | gateway/cargo/BUILD.bazel | 130 | ||||
| -rw-r--r-- | gateway/src/payloads/gateway.rs | 62 |
2 files changed, 159 insertions, 33 deletions
diff --git a/gateway/cargo/BUILD.bazel b/gateway/cargo/BUILD.bazel new file mode 100644 index 0000000..e85683f --- /dev/null +++ b/gateway/cargo/BUILD.bazel @@ -0,0 +1,130 @@ +""" +@generated +cargo-raze generated Bazel file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +package(default_visibility = ["//visibility:public"]) + +licenses([ + "notice", # See individual crates for specific licenses +]) + +# Aliased targets +alias( + name = "enumflags2", + actual = "@raze__enumflags2__0_7_1//:enumflags2", + tags = [ + "cargo-raze", + "manual", + ], +) + +alias( + name = "futures", + actual = "@raze__futures__0_3_17//:futures", + tags = [ + "cargo-raze", + "manual", + ], +) + +alias( + name = "futures_util", + actual = "@raze__futures_util__0_3_17//:futures_util", + tags = [ + "cargo-raze", + "manual", + ], +) + +alias( + name = "log", + actual = "@raze__log__0_4_14//:log", + tags = [ + "cargo-raze", + "manual", + ], +) + +alias( + name = "num", + actual = "@raze__num__0_4_0//:num", + tags = [ + "cargo-raze", + "manual", + ], +) + +alias( + name = "num_derive", + actual = "@raze__num_derive__0_3_3//:num_derive", + tags = [ + "cargo-raze", + "manual", + ], +) + +alias( + name = "num_traits", + actual = "@raze__num_traits__0_2_14//:num_traits", + tags = [ + "cargo-raze", + "manual", + ], +) + +alias( + name = "serde", + actual = "@raze__serde__1_0_130//:serde", + tags = [ + "cargo-raze", + "manual", + ], +) + +alias( + name = "serde_json", + actual = "@raze__serde_json__1_0_67//:serde_json", + tags = [ + "cargo-raze", + "manual", + ], +) + +alias( + name = "serde_repr", + actual = "@raze__serde_repr__0_1_7//:serde_repr", + tags = [ + "cargo-raze", + "manual", + ], +) + +alias( + name = "tokio", + actual = "@raze__tokio__1_11_0//:tokio", + tags = [ + "cargo-raze", + "manual", + ], +) + +alias( + name = "tokio_tungstenite", + actual = "@raze__tokio_tungstenite__0_15_0//:tokio_tungstenite", + tags = [ + "cargo-raze", + "manual", + ], +) + +alias( + name = "url", + actual = "@raze__url__2_2_2//:url", + tags = [ + "cargo-raze", + "manual", + ], +) diff --git a/gateway/src/payloads/gateway.rs b/gateway/src/payloads/gateway.rs index fe77e7c..4f24890 100644 --- a/gateway/src/payloads/gateway.rs +++ b/gateway/src/payloads/gateway.rs @@ -1,7 +1,10 @@ -use super::{dispatch::Dispatch, opcodes::{OpCodes, hello::Hello}}; +use super::{ + dispatch::Dispatch, + opcodes::{hello::Hello, OpCodes}, +}; +use serde::de::Error; use serde::{Deserialize, Serialize}; use serde_json::Value; -use serde::de::Error; #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] #[serde(bound(deserialize = "T: Deserialize<'de> + std::fmt::Debug"))] @@ -24,7 +27,10 @@ pub enum Message { } impl<'de> serde::Deserialize<'de> for Message { - fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> where D::Error : Error { + fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> + where + D::Error: Error, + { let value = Value::deserialize(d)?; let val = value.get("op").and_then(Value::as_u64).unwrap(); @@ -37,41 +43,31 @@ impl<'de> serde::Deserialize<'de> for Message { // we need to find a better solution than clone match Dispatch::deserialize(value) { - Ok(data) => { - Ok(Message::Dispatch(BaseMessage { - op, - t, - sequence, - data - })) - }, - Err(e) => Err(Error::custom(e)), - } - }, - - OpCodes::Reconnect => { - match BaseMessage::deserialize(value) { - Ok(data) => Ok(Message::Reconnect(data)), + Ok(data) => Ok(Message::Dispatch(BaseMessage { + op, + t, + sequence, + data, + })), Err(e) => Err(Error::custom(e)), } + } + + OpCodes::Reconnect => match BaseMessage::deserialize(value) { + Ok(data) => Ok(Message::Reconnect(data)), + Err(e) => Err(Error::custom(e)), }, - OpCodes::InvalidSession => { - match BaseMessage::deserialize(value) { - Ok(data) => Ok(Message::InvalidSession(data)), - Err(e) => Err(Error::custom(e)), - } + OpCodes::InvalidSession => match BaseMessage::deserialize(value) { + Ok(data) => Ok(Message::InvalidSession(data)), + Err(e) => Err(Error::custom(e)), }, - OpCodes::Hello => { - match BaseMessage::deserialize(value) { - Ok(data) => Ok(Message::Hello(data)), - Err(e) => Err(Error::custom(e)), - } + OpCodes::Hello => match BaseMessage::deserialize(value) { + Ok(data) => Ok(Message::Hello(data)), + Err(e) => Err(Error::custom(e)), }, - OpCodes::HeartbeatACK => { - match BaseMessage::deserialize(value) { - Ok(data) => Ok(Message::HeartbeatACK(data)), - Err(e) => Err(Error::custom(e)), - } + OpCodes::HeartbeatACK => match BaseMessage::deserialize(value) { + Ok(data) => Ok(Message::HeartbeatACK(data)), + Err(e) => Err(Error::custom(e)), }, _ => panic!("Cannot convert"), } |
