Skip to content

Commit

Permalink
Merge pull request #1 from UkoeHB/upver
Browse files Browse the repository at this point in the history
Update to tokio-tungstenite v0.20
  • Loading branch information
TannerRogalsky authored Oct 7, 2023
2 parents ddeedf5 + fb8a6e4 commit fa820ff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ httparse = "1.3.4"
futures-util = { version = "0.3", default-features = false, features = ["sink", "std"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio-tungstenite = "0.16"
tokio-tungstenite = "0.20"
tokio = { version = "1.15", default-features = false, features = ["net"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
11 changes: 7 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,21 @@ pub enum Error {
/// Protocol violation.
#[error("WebSocket protocol error: {0}")]
Protocol(#[from] ProtocolError),
/// Message send queue full.
#[error("Send queue is full")]
SendQueueFull(crate::Message),
/// Message write buffer is full.
#[error("Write buffer is full")]
WriteBufferFull(crate::Message),
/// UTF coding error.
#[error("UTF-8 encoding error")]
Utf8,
/// Attack attempt detected.
#[error("Attack attempt detected")]
AttackAttempt,
/// Invalid URL.
#[error("URL error: {0}")]
Url(#[from] UrlError),
/// HTTP error.
#[error("HTTP error: {}", .0.status())]
Http(Response<Option<String>>),
Http(Response<Option<Vec<u8>>>),
/// HTTP format error.
#[error("HTTP format error: {0}")]
HttpFormat(#[from] http::Error),
Expand Down
12 changes: 9 additions & 3 deletions src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn msg_conv(msg: Result<Message>) -> MsgConvFut {
Message::Text(inner) => Ok(crate::Message::Text(inner)),
Message::Binary(inner) => Ok(crate::Message::Binary(inner)),
Message::Close(inner) => Ok(crate::Message::Close(inner.map(Into::into))),
Message::Ping(_) | Message::Pong(_) => return None,
Message::Ping(_) | Message::Pong(_) | Message::Frame(_) => return None,
},
Err(err) => Err(crate::Error::from(err)),
};
Expand Down Expand Up @@ -113,7 +113,9 @@ impl From<Message> for crate::Message {
Message::Text(inner) => crate::Message::Text(inner),
Message::Binary(inner) => crate::Message::Binary(inner),
Message::Close(inner) => crate::Message::Close(inner.map(Into::into)),
Message::Ping(_) | Message::Pong(_) => unreachable!("Unsendable via interface."),
Message::Ping(_) | Message::Pong(_) | Message::Frame(_) => {
unreachable!("Unsendable via interface.")
}
}
}
}
Expand All @@ -137,8 +139,9 @@ impl From<Error> for crate::Error {
Error::Tls(inner) => crate::Error::Tls(inner.into()),
Error::Capacity(inner) => crate::Error::Capacity(inner.into()),
Error::Protocol(inner) => crate::Error::Protocol(inner.into()),
Error::SendQueueFull(inner) => crate::Error::SendQueueFull(inner.into()),
Error::WriteBufferFull(inner) => crate::Error::WriteBufferFull(inner.into()),
Error::Utf8 => crate::Error::Utf8,
Error::AttackAttempt => crate::Error::AttackAttempt,
Error::Url(inner) => crate::Error::Url(inner.into()),
Error::Http(inner) => crate::Error::Http(inner),
Error::HttpFormat(inner) => crate::Error::HttpFormat(inner),
Expand Down Expand Up @@ -194,6 +197,9 @@ impl From<ProtocolError> for crate::error::ProtocolError {
ProtocolError::CustomResponseSuccessful => {
crate::error::ProtocolError::CustomResponseSuccessful
}
ProtocolError::InvalidHeader(header_name) => {
crate::error::ProtocolError::InvalidHeader(header_name)
}
ProtocolError::HandshakeIncomplete => crate::error::ProtocolError::HandshakeIncomplete,
ProtocolError::HttparseError(inner) => {
crate::error::ProtocolError::HttparseError(inner)
Expand Down

0 comments on commit fa820ff

Please sign in to comment.