diff --git a/Cargo.lock b/Cargo.lock index fddda0d..05d7485 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -434,9 +434,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "caret" @@ -3149,9 +3149,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.24.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" +checksum = "be4bf6fecd69fcdede0ec680aaf474cdab988f9de6bc73d3758f0160e3b7025a" dependencies = [ "futures-util", "log", @@ -4283,9 +4283,9 @@ dependencies = [ [[package]] name = "tungstenite" -version = "0.24.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18e5b8366ee7a95b16d32197d0b2604b43a0be89dc5fac9f8e96ccafbaedda8a" +checksum = "413083a99c579593656008130e29255e54dcaae495be556cc26888f211648c24" dependencies = [ "byteorder", "bytes", @@ -4297,7 +4297,7 @@ dependencies = [ "rustls", "rustls-pki-types", "sha1", - "thiserror 1.0.64", + "thiserror 2.0.9", "utf-8", ] diff --git a/Cargo.toml b/Cargo.toml index 7fbf67f..ad4bc65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ url = { version = "2.5", default-features = false } tokio = { version = "1", features = ["net", "time"] } tokio-rustls = { version = "0.26", default-features = false, features = ["ring", "tls12"] } # Required to enable the necessary features for tokio-tungstenite tokio-socks = { version = "0.5", optional = true } -tokio-tungstenite = { version = "0.24", features = ["rustls-tls-webpki-roots"] } +tokio-tungstenite = { version = "0.26", features = ["rustls-tls-webpki-roots"] } # TOR deps arti-client = { version = "0.26", default-features = false, features = ["onion-service-client", "rustls", "static-sqlite", "tokio"], optional = true } diff --git a/src/message.rs b/src/message.rs index d77cee7..0c9b093 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,9 +1,6 @@ // Copyright (c) 2022-2024 Yuki Kishimoto // Distributed under the MIT software license -#[cfg(not(target_arch = "wasm32"))] -use std::borrow::Cow; - #[cfg(not(target_arch = "wasm32"))] use tokio_tungstenite::tungstenite::protocol::frame::coding::CloseCode; #[cfg(not(target_arch = "wasm32"))] @@ -72,11 +69,11 @@ pub enum Message { // } #[cfg(not(target_arch = "wasm32"))] -impl From for TungsteniteCloseFrame<'_> { +impl From for TungsteniteCloseFrame { fn from(frame: CloseFrame) -> Self { Self { code: CloseCode::from(frame.code), - reason: Cow::Owned(frame.reason), + reason: frame.reason.into(), } } } @@ -85,21 +82,21 @@ impl From for TungsteniteCloseFrame<'_> { impl From for TungsteniteMessage { fn from(msg: Message) -> Self { match msg { - Message::Text(text) => Self::Text(text), - Message::Binary(data) => Self::Binary(data), - Message::Ping(data) => Self::Ping(data), - Message::Pong(data) => Self::Pong(data), + Message::Text(text) => Self::Text(text.into()), + Message::Binary(data) => Self::Binary(data.into()), + Message::Ping(data) => Self::Ping(data.into()), + Message::Pong(data) => Self::Pong(data.into()), Message::Close(frame) => Self::Close(frame.map(|f| f.into())), } } } #[cfg(not(target_arch = "wasm32"))] -impl From> for CloseFrame { - fn from(frame: TungsteniteCloseFrame<'_>) -> Self { +impl From for CloseFrame { + fn from(frame: TungsteniteCloseFrame) -> Self { Self { code: frame.code.into(), - reason: frame.reason.into_owned(), + reason: frame.reason.to_string(), } } } @@ -108,10 +105,10 @@ impl From> for CloseFrame { impl From for Message { fn from(msg: TungsteniteMessage) -> Self { match msg { - TungsteniteMessage::Text(text) => Self::Text(text), - TungsteniteMessage::Binary(data) => Self::Binary(data), - TungsteniteMessage::Ping(data) => Self::Ping(data), - TungsteniteMessage::Pong(data) => Self::Pong(data), + TungsteniteMessage::Text(text) => Self::Text(text.to_string()), + TungsteniteMessage::Binary(data) => Self::Binary(data.to_vec()), + TungsteniteMessage::Ping(data) => Self::Ping(data.to_vec()), + TungsteniteMessage::Pong(data) => Self::Pong(data.to_vec()), TungsteniteMessage::Close(frame) => Self::Close(frame.map(|f| f.into())), // SAFETY: from tungstenite docs: "you're not going to get this value while reading the message". // SAFETY: this conversion is used only in Stream trait, so when reading the messages.