diff --git a/src/gateway/backends/mod.rs b/src/gateway/backends/mod.rs new file mode 100644 index 0000000..53123fe --- /dev/null +++ b/src/gateway/backends/mod.rs @@ -0,0 +1,9 @@ +#[cfg(not(target_arch = "wasm32"))] +pub mod tungstenite; + +#[cfg(not(target_arch = "wasm32"))] +pub type Sink = tungstenite::TungsteniteSink; +#[cfg(not(target_arch = "wasm32"))] +pub type Stream = tungstenite::TungsteniteStream; +#[cfg(not(target_arch = "wasm32"))] +pub type WebSocketBackend = tungstenite::TungsteniteBackend; diff --git a/src/gateway/backend_tungstenite.rs b/src/gateway/backends/tungstenite.rs similarity index 98% rename from src/gateway/backend_tungstenite.rs rename to src/gateway/backends/tungstenite.rs index f99424d..5184329 100644 --- a/src/gateway/backend_tungstenite.rs +++ b/src/gateway/backends/tungstenite.rs @@ -7,8 +7,8 @@ use tokio_tungstenite::{ connect_async_tls_with_config, tungstenite, Connector, MaybeTlsStream, WebSocketStream, }; -use super::GatewayMessage; use crate::errors::GatewayError; +use crate::gateway::GatewayMessage; #[derive(Debug, Clone)] pub struct TungsteniteBackend; diff --git a/src/gateway/mod.rs b/src/gateway/mod.rs index 03ac502..076ed54 100644 --- a/src/gateway/mod.rs +++ b/src/gateway/mod.rs @@ -1,13 +1,13 @@ use async_trait::async_trait; -#[cfg(not(target_arch = "wasm32"))] -pub mod backend_tungstenite; +pub mod backends; pub mod events; pub mod gateway; pub mod handle; pub mod heartbeat; pub mod message; +pub use backends::*; pub use gateway::*; pub use handle::*; use heartbeat::*; @@ -22,13 +22,6 @@ use std::sync::{Arc, RwLock}; use tokio::sync::Mutex; -#[cfg(not(target_arch = "wasm32"))] -pub type Sink = backend_tungstenite::TungsteniteSink; -#[cfg(not(target_arch = "wasm32"))] -pub type Stream = backend_tungstenite::TungsteniteStream; -#[cfg(not(target_arch = "wasm32"))] -pub type WebSocketBackend = backend_tungstenite::TungsteniteBackend; - // Gateway opcodes /// Opcode received when the server dispatches a [crate::types::WebSocketEvent] const GATEWAY_DISPATCH: u8 = 0;