From f8795adc350b46fd7e2623ec26bf197b6d208341 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Thu, 16 Nov 2023 17:47:40 +0100 Subject: [PATCH] Make message.rs shared Make HeartbeatThreadCommunication shared Move shared code to mod.rs Export new shared code Remove useless export --- src/gateway/default/heartbeat.rs | 10 ---------- src/gateway/default/mod.rs | 2 -- src/gateway/{default => }/message.rs | 0 src/gateway/mod.rs | 13 ++++++++++++- 4 files changed, 12 insertions(+), 13 deletions(-) rename src/gateway/{default => }/message.rs (100%) diff --git a/src/gateway/default/heartbeat.rs b/src/gateway/default/heartbeat.rs index 4c30496..8a6a8b5 100644 --- a/src/gateway/default/heartbeat.rs +++ b/src/gateway/default/heartbeat.rs @@ -146,13 +146,3 @@ impl DefaultHeartbeatHandler { } } } - -/// Used for communications between the heartbeat and gateway thread. -/// Either signifies a sequence number update, a heartbeat ACK or a Heartbeat request by the server -#[derive(Clone, Copy, Debug)] -pub struct HeartbeatThreadCommunication { - /// The opcode for the communication we received, if relevant - pub op_code: Option, - /// The sequence number we got from discord, if any - pub sequence_number: Option, -} diff --git a/src/gateway/default/mod.rs b/src/gateway/default/mod.rs index 4843b96..8ec29e8 100644 --- a/src/gateway/default/mod.rs +++ b/src/gateway/default/mod.rs @@ -1,13 +1,11 @@ pub mod gateway; pub mod handle; pub mod heartbeat; -pub mod message; use super::*; pub use gateway::*; pub use handle::*; use heartbeat::*; -pub use message::*; use tokio_tungstenite::tungstenite::Message; use crate::errors::GatewayError; diff --git a/src/gateway/default/message.rs b/src/gateway/message.rs similarity index 100% rename from src/gateway/default/message.rs rename to src/gateway/message.rs diff --git a/src/gateway/mod.rs b/src/gateway/mod.rs index c33e7cb..bdf150d 100644 --- a/src/gateway/mod.rs +++ b/src/gateway/mod.rs @@ -1,11 +1,13 @@ #[cfg(all(not(target_arch = "wasm32"), feature = "client"))] pub mod default; pub mod events; +pub mod message; #[cfg(all(target_arch = "wasm32", feature = "client"))] pub mod wasm; #[cfg(all(not(target_arch = "wasm32"), feature = "client"))] pub use default::*; +pub use message::*; #[cfg(all(target_arch = "wasm32", feature = "client"))] pub use wasm::*; @@ -23,7 +25,6 @@ use std::sync::{Arc, RwLock}; use std::time::Duration; use async_trait::async_trait; -use default::heartbeat::HeartbeatThreadCommunication; use futures_util::stream::SplitSink; use futures_util::Sink; use futures_util::{SinkExt, Stream}; @@ -87,6 +88,16 @@ const GATEWAY_LAZY_REQUEST: u8 = 14; pub type ObservableObject = dyn Send + Sync + Any; +/// Used for communications between the heartbeat and gateway thread. +/// Either signifies a sequence number update, a heartbeat ACK or a Heartbeat request by the server +#[derive(Clone, Copy, Debug)] +pub struct HeartbeatThreadCommunication { + /// The opcode for the communication we received, if relevant + pub op_code: Option, + /// The sequence number we got from discord, if any + pub sequence_number: Option, +} + /// An entity type which is supposed to be updateable via the Gateway. This is implemented for all such types chorus supports, implementing it for your own types is likely a mistake. pub trait Updateable: 'static + Send + Sync { fn id(&self) -> Snowflake;