Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump tokio-tungstenite to 0.26.1 #1112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ tokio = { version = "1.0", features = ["fs", "sync", "time"] }
tokio-util = { version = "0.7.1", features = ["io"] }
tracing = { version = "0.1.21", default-features = false, features = ["log", "std"] }
tower-service = "0.3"
tokio-tungstenite = { version = "0.21", optional = true }
tokio-tungstenite = { version = "0.26.1", optional = true }
percent-encoding = "2.1"
pin-project = "1.0"
tokio-rustls = { version = "0.26", default-features = false, features = ["logging", "tls12", "ring"], optional = true }
Expand Down
24 changes: 12 additions & 12 deletions src/filters/ws.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Websockets Filters

use std::borrow::Cow;
use std::fmt;
use std::future::Future;
use std::pin::Pin;
Expand All @@ -14,6 +13,7 @@ use futures_util::{future, ready, FutureExt, Sink, Stream, TryFutureExt};
use headers::{Connection, HeaderMapExt, SecWebsocketAccept, SecWebsocketKey, Upgrade};
use hyper::upgrade::OnUpgrade;
use tokio_tungstenite::{
tungstenite::Bytes, tungstenite::Utf8Bytes,
tungstenite::protocol::{self, WebSocketConfig},
WebSocketStream,
};
Expand Down Expand Up @@ -284,23 +284,23 @@ pub struct Message {

impl Message {
/// Construct a new Text `Message`.
pub fn text<S: Into<String>>(s: S) -> Message {
pub fn text<B: Into<Utf8Bytes>>(bytes: B) -> Message {
Message {
inner: protocol::Message::text(s),
inner: protocol::Message::text(bytes.into()),
}
}

/// Construct a new Binary `Message`.
pub fn binary<V: Into<Vec<u8>>>(v: V) -> Message {
pub fn binary<B: Into<Bytes>>(bytes: B) -> Message {
Message {
inner: protocol::Message::binary(v),
inner: protocol::Message::binary(bytes),
}
}

/// Construct a new Ping `Message`.
pub fn ping<V: Into<Vec<u8>>>(v: V) -> Message {
pub fn ping<B: Into<Bytes>>(bytes: B) -> Message {
Message {
inner: protocol::Message::Ping(v.into()),
inner: protocol::Message::Ping(bytes.into()),
}
}

Expand All @@ -309,9 +309,9 @@ impl Message {
/// Note that one rarely needs to manually construct a Pong message because the underlying tungstenite socket
/// automatically responds to the Ping messages it receives. Manual construction might still be useful in some cases
/// like in tests or to send unidirectional heartbeats.
pub fn pong<V: Into<Vec<u8>>>(v: V) -> Message {
pub fn pong<B: Into<Bytes>>(bytes: B) -> Message {
Message {
inner: protocol::Message::Pong(v.into()),
inner: protocol::Message::Pong(bytes.into()),
}
}

Expand All @@ -323,7 +323,7 @@ impl Message {
}

/// Construct a Close `Message` with a code and reason.
pub fn close_with(code: impl Into<u16>, reason: impl Into<Cow<'static, str>>) -> Message {
pub fn close_with(code: impl Into<u16>, reason: impl Into<Utf8Bytes>) -> Message {
Message {
inner: protocol::Message::Close(Some(protocol::frame::CloseFrame {
code: protocol::frame::coding::CloseCode::from(code.into()),
Expand Down Expand Up @@ -387,7 +387,7 @@ impl Message {
}

/// Destructure this message into binary data.
pub fn into_bytes(self) -> Vec<u8> {
pub fn into_bytes(self) -> Bytes {
self.inner.into_data()
}
}
Expand All @@ -398,7 +398,7 @@ impl fmt::Debug for Message {
}
}

impl From<Message> for Vec<u8> {
impl From<Message> for Bytes {
fn from(m: Message) -> Self {
m.into_bytes()
}
Expand Down
2 changes: 1 addition & 1 deletion src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ impl WsBuilder {
impl WsClient {
/// Send a "text" websocket message to the server.
pub async fn send_text(&mut self, text: impl Into<String>) {
self.send(crate::ws::Message::text(text)).await;
self.send(crate::ws::Message::text(text.into())).await;
}

/// Send a websocket message to the server.
Expand Down