Skip to content

Commit

Permalink
ws protocol: make tungstenite integration optional feature
Browse files Browse the repository at this point in the history
  • Loading branch information
greatest-ape committed Jan 29, 2024
1 parent fee465d commit 3c906f4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/ws_protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ rust-version.workspace = true

readme = "./README.md"

[features]
default = ["tungstenite"]
tungstenite = ["dep:tungstenite"]

[lib]
name = "aquatic_ws_protocol"

Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions crates/ws_protocol/src/incoming/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub enum InMessage {
ScrapeRequest(ScrapeRequest),
}

#[cfg(feature = "tungstenite")]
impl InMessage {
#[inline]
pub fn to_ws_message(&self) -> ::tungstenite::Message {
Expand Down
2 changes: 2 additions & 0 deletions crates/ws_protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
1 change: 1 addition & 0 deletions crates/ws_protocol/src/outgoing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub enum OutMessage {
ErrorResponse(ErrorResponse),
}

#[cfg(feature = "tungstenite")]
impl OutMessage {
#[inline]
pub fn to_ws_message(&self) -> tungstenite::Message {
Expand Down

0 comments on commit 3c906f4

Please sign in to comment.