Skip to content

Commit

Permalink
Bump tokio-tungenstenite to 0.24
Browse files Browse the repository at this point in the history
  • Loading branch information
TannerRogalsky committed Dec 12, 2024
1 parent 3e2045d commit 2a1d46b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ futures-util = { version = "0.3", default-features = false, features = [


[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio-tungstenite = "0.21"
tokio-tungstenite = "0.24"
tokio = { version = "1.36", default-features = false, features = ["net"] }
native-tls = { version = "0.2", default-features = false, optional = true }
rustls = { version = "0.22", default-features = false, optional = true }
rustls = { version = "0.23", default-features = false, optional = true }


[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
20 changes: 20 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ pub enum CapacityError {
},
}

/// Indicates the specific type/cause of a subprotocol header error.
#[derive(Error, Clone, PartialEq, Eq, Debug, Copy)]
pub enum SubProtocolError {
/// The server sent a subprotocol to a client handshake request but none was requested
#[error("Server sent a subprotocol but none was requested")]
ServerSentSubProtocolNoneRequested,

/// The server sent an invalid subprotocol to a client handhshake request
#[error("Server sent an invalid subprotocol")]
InvalidSubProtocol,

/// The server sent no subprotocol to a client handshake request that requested one or more
/// subprotocols
#[error("Server sent no subprotocol")]
NoSubProtocol,
}

/// Indicates the specific type/cause of a protocol error.
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum ProtocolError {
Expand All @@ -169,6 +186,9 @@ pub enum ProtocolError {
/// The `Sec-WebSocket-Accept` header is either not present or does not specify the correct key value.
#[error("Key mismatch in \"Sec-WebSocket-Accept\" header")]
SecWebSocketAcceptKeyMismatch,
/// The `Sec-WebSocket-Protocol` header was invalid
#[error("SubProtocol error: {0}")]
SecWebSocketSubProtocolError(SubProtocolError),

Check failure on line 191 in src/error.rs

View workflow job for this annotation

GitHub Actions / Clippy

variant name ends with the enum's name
/// Garbage data encountered after client request.
#[error("Junk after client request")]
JunkAfterRequest,
Expand Down
17 changes: 17 additions & 0 deletions src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ impl From<ProtocolError> for crate::error::ProtocolError {
ProtocolError::InvalidCloseSequence => {
crate::error::ProtocolError::InvalidCloseSequence
}
ProtocolError::SecWebSocketSubProtocolError(sub_protocol_error) => {
crate::error::ProtocolError::SecWebSocketSubProtocolError(sub_protocol_error.into())
}
}
}
}
Expand All @@ -258,6 +261,20 @@ impl From<TlsError> for crate::error::TlsError {
}
}

impl From<SubProtocolError> for crate::error::SubProtocolError {
fn from(error: SubProtocolError) -> Self {
match error {
SubProtocolError::ServerSentSubProtocolNoneRequested => {
crate::error::SubProtocolError::ServerSentSubProtocolNoneRequested
}
SubProtocolError::InvalidSubProtocol => {
crate::error::SubProtocolError::InvalidSubProtocol
}
SubProtocolError::NoSubProtocol => crate::error::SubProtocolError::NoSubProtocol,
}
}
}

impl From<Data> for crate::error::Data {
fn from(data: Data) -> Self {
match data {
Expand Down

0 comments on commit 2a1d46b

Please sign in to comment.