diff --git a/crates/ws_protocol/Cargo.toml b/crates/ws_protocol/Cargo.toml index 4ae72de..3c2dd4a 100644 --- a/crates/ws_protocol/Cargo.toml +++ b/crates/ws_protocol/Cargo.toml @@ -12,6 +12,10 @@ rust-version.workspace = true readme = "./README.md" +[features] +default = ["tungstenite"] +tungstenite = ["dep:tungstenite"] + [lib] name = "aquatic_ws_protocol" @@ -26,7 +30,7 @@ hashbrown = { version = "0.14", features = ["serde"] } serde = { version = "1", features = ["derive"] } serde_json = "1" simd-json = "0.13" -tungstenite = "0.21" +tungstenite = { version = "0.21", optional = true } [dev-dependencies] criterion = "0.5" diff --git a/crates/ws_protocol/src/incoming/mod.rs b/crates/ws_protocol/src/incoming/mod.rs index 1fe48a3..517a319 100644 --- a/crates/ws_protocol/src/incoming/mod.rs +++ b/crates/ws_protocol/src/incoming/mod.rs @@ -15,6 +15,7 @@ pub enum InMessage { ScrapeRequest(ScrapeRequest), } +#[cfg(feature = "tungstenite")] impl InMessage { #[inline] pub fn to_ws_message(&self) -> ::tungstenite::Message { diff --git a/crates/ws_protocol/src/lib.rs b/crates/ws_protocol/src/lib.rs index 2652e86..1c91b00 100644 --- a/crates/ws_protocol/src/lib.rs +++ b/crates/ws_protocol/src/lib.rs @@ -227,6 +227,7 @@ mod tests { } } + #[cfg(feature = "tungstenite")] #[quickcheck] fn quickcheck_serde_identity_in_message(in_message_1: InMessage) -> bool { let ws_message = in_message_1.to_ws_message(); @@ -246,6 +247,7 @@ mod tests { success } + #[cfg(feature = "tungstenite")] #[quickcheck] fn quickcheck_serde_identity_out_message(out_message_1: OutMessage) -> bool { let ws_message = out_message_1.to_ws_message(); diff --git a/crates/ws_protocol/src/outgoing/mod.rs b/crates/ws_protocol/src/outgoing/mod.rs index c2fbaab..151fb4b 100644 --- a/crates/ws_protocol/src/outgoing/mod.rs +++ b/crates/ws_protocol/src/outgoing/mod.rs @@ -23,6 +23,7 @@ pub enum OutMessage { ErrorResponse(ErrorResponse), } +#[cfg(feature = "tungstenite")] impl OutMessage { #[inline] pub fn to_ws_message(&self) -> tungstenite::Message {