Skip to content

Commit

Permalink
chore(deps): update tokio-tungstenite requirement from 0.25 to 0.26
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn committed Dec 18, 2024
1 parent 11e28a2 commit 6d020c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ tokio-native-tls = "0.3"
tokio-rustls = {version = "0.26", default-features = false }
tokio-openssl = "0.6"
tokio-stream = { version = "0.1", default-features = false }
tokio-tungstenite = { version = "0.25", default-features = false }
tokio-tungstenite = { version = "0.26", default-features = false }
tokio-util = "0.7"
tower = { version = "0.5", default-features = false }
tracing-subscriber = { version = "0.3" }
Expand Down
27 changes: 14 additions & 13 deletions crates/extra/src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
//! "#;
//!```
use std::borrow::Cow;
use std::fmt::{self, Debug, Formatter};
use std::future::Future;
use std::pin::Pin;
Expand All @@ -94,8 +93,10 @@ use salvo_core::http::headers::{
use salvo_core::http::{StatusCode, StatusError};
use salvo_core::rt::tokio::TokioIo;
use salvo_core::{Error, Request, Response};
use tokio_tungstenite::tungstenite::protocol::frame::{Payload, Utf8Payload};
use tokio_tungstenite::tungstenite::protocol::frame::coding::CloseCode;
use tokio_tungstenite::tungstenite::protocol::frame::{CloseFrame, Utf8Bytes};
use tokio_tungstenite::tungstenite::protocol::{self, WebSocketConfig};
use tokio_tungstenite::tungstenite::Bytes;
use tokio_tungstenite::WebSocketStream;

/// Creates a WebSocket Handler.
Expand Down Expand Up @@ -391,31 +392,31 @@ pub struct Message {
impl Message {
/// Construct a new Text `Message`.
#[inline]
pub fn text<S: Into<Utf8Payload>>(s: S) -> Message {
pub fn text<S: Into<Utf8Bytes>>(s: S) -> Message {
Message {
inner: protocol::Message::text(s),
}
}

/// Construct a new Binary `Message`.
#[inline]
pub fn binary<V: Into<Payload>>(v: V) -> Message {
pub fn binary<V: Into<Bytes>>(v: V) -> Message {
Message {
inner: protocol::Message::binary(v),
}
}

/// Construct a new Ping `Message`.
#[inline]
pub fn ping<V: Into<Payload>>(v: V) -> Message {
pub fn ping<V: Into<Bytes>>(v: V) -> Message {
Message {
inner: protocol::Message::Ping(v.into()),
}
}

/// Construct a new Pong `Message`.
#[inline]
pub fn pong<V: Into<Payload>>(v: V) -> Message {
pub fn pong<V: Into<Bytes>>(v: V) -> Message {
Message {
inner: protocol::Message::Pong(v.into()),
}
Expand All @@ -431,10 +432,10 @@ impl Message {

/// Construct a Close `Message` with a code and reason.
#[inline]
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()),
inner: protocol::Message::Close(Some(CloseFrame {
code: CloseCode::from(code.into()),
reason: reason.into(),
})),
}
Expand Down Expand Up @@ -493,10 +494,10 @@ impl Message {
#[inline]
pub fn as_bytes(&self) -> &[u8] {
match &self.inner {
protocol::Message::Text(s) => s.as_slice(),
protocol::Message::Binary(v) => v.as_slice(),
protocol::Message::Ping(v) => v.as_slice(),
protocol::Message::Pong(v) => v.as_slice(),
protocol::Message::Text(s) => s.as_bytes(),
protocol::Message::Binary(v) => v.as_ref(),
protocol::Message::Ping(v) => v.as_ref(),
protocol::Message::Pong(v) => v.as_ref(),
protocol::Message::Close(_) => &[],
protocol::Message::Frame(v) => v.payload(),
}
Expand Down

0 comments on commit 6d020c9

Please sign in to comment.