diff --git a/src/gateway/mod.rs b/src/gateway/mod.rs index ebd06cc..b6bd031 100644 --- a/src/gateway/mod.rs +++ b/src/gateway/mod.rs @@ -7,6 +7,7 @@ pub use gateway::*; pub use handle::*; use heartbeat::*; pub use message::*; +use tokio_tungstenite::tungstenite::Message; use crate::errors::GatewayError; use crate::types::{Snowflake, WebSocketEvent}; @@ -21,8 +22,8 @@ use tokio::time::sleep_until; use futures_util::stream::SplitSink; use futures_util::stream::SplitStream; -use futures_util::SinkExt; -use futures_util::StreamExt; +use futures_util::{Sink, StreamExt}; +use futures_util::{SinkExt, Stream}; use log::{info, trace, warn}; use tokio::net::TcpStream; use tokio::sync::mpsc::Sender; @@ -34,6 +35,8 @@ use tokio::time::Instant; use tokio_tungstenite::MaybeTlsStream; use tokio_tungstenite::{connect_async_tls_with_config, Connector, WebSocketStream}; +use self::event::Events; + // Gateway opcodes /// Opcode received when the server dispatches a [crate::types::WebSocketEvent] const GATEWAY_DISPATCH: u8 = 0; @@ -135,8 +138,35 @@ impl GatewayEvent { } } +#[allow(clippy::type_complexity)] +pub trait GatewayCapable +where + R: Stream, + S: Sink, +{ + fn get_events(&self) -> Arc>; + fn get_websocket_send(&self) -> Arc>>; + fn get_store(&self) -> GatewayStore; + fn get_url(&self) -> String; + #[allow(clippy::new_ret_no_self)] + #[allow(clippy::wrong_self_convention)] + /// TODO: Explain what this method has to do to be a good new() impl, or link to such documentation + fn new( + &self, + websocket_url: &'static str, + ) -> Result>, R, S>>, GatewayError>; +} + +pub trait GatewayHandleCapable +where + T: GatewayCapable, + R: Stream, + S: Sink, +{ +} + #[cfg(test)] -mod example { +mod test { use crate::types; use super::*;