Skip to content

Commit f0072d1

Browse files
Cabbachearqunis
authored andcommitted
Update tokio-tungstenite to v0.26.1
1 parent 872e19c commit f0072d1

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ chrono = { version = "0.4.31", default-features = false, features = ["clock", "s
5555
flate2 = { version = "1.0.28", optional = true }
5656
zstd-safe = { version = "7.2.1", optional = true }
5757
reqwest = { version = "0.12.2", default-features = false, features = ["multipart", "stream", "json"], optional = true }
58-
tokio-tungstenite = { version = "0.24.0", features = ["url"], optional = true }
58+
tokio-tungstenite = { version = "0.26.1", features = ["url"], optional = true }
5959
percent-encoding = { version = "2.3.0", optional = true }
6060
mini-moka = { version = "0.10.2", optional = true }
6161
mime_guess = { version = "2.0.4", optional = true }

src/gateway/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub enum Error {
1313
/// There was an error building a URL.
1414
BuildingUrl,
1515
/// The connection closed, potentially uncleanly.
16-
Closed(Option<CloseFrame<'static>>),
16+
Closed(Option<CloseFrame>),
1717
/// Expected a Hello during a handshake
1818
ExpectedHello,
1919
/// When there was an error sending a heartbeat.

src/gateway/sharding/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl Shard {
383383
}
384384

385385
#[cfg_attr(feature = "tracing_instrument", instrument(skip(self)))]
386-
fn handle_gateway_closed(&mut self, data: Option<&CloseFrame<'static>>) -> Result<()> {
386+
fn handle_gateway_closed(&mut self, data: Option<&CloseFrame>) -> Result<()> {
387387
if let Some(code) = data.map(|d| d.code) {
388388
match CloseCode(code.into()) {
389389
CloseCode::UnknownError => warn!("[{:?}] Unknown gateway error.", self.shard_info),

src/gateway/sharding/shard_runner.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::borrow::Cow;
21
use std::sync::Arc;
32

43
use futures::channel::mpsc::{self, UnboundedReceiver as Receiver, UnboundedSender as Sender};
@@ -245,7 +244,7 @@ impl ShardRunner {
245244
.client
246245
.close(Some(CloseFrame {
247246
code: close_code.into(),
248-
reason: Cow::from(""),
247+
reason: "".into(),
249248
}))
250249
.await,
251250
);
@@ -308,7 +307,7 @@ impl ShardRunner {
308307
let reason = reason.unwrap_or_default();
309308
let close = CloseFrame {
310309
code: code.into(),
311-
reason: Cow::from(reason),
310+
reason: reason.into(),
312311
};
313312
self.shard.client.close(Some(close)).await.is_ok()
314313
},

src/gateway/ws.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,14 @@ const TIMEOUT: Duration = Duration::from_millis(500);
228228

229229
impl WsClient {
230230
pub(crate) async fn connect(url: Url, compression: TransportCompression) -> Result<Self> {
231-
let config = WebSocketConfig {
232-
max_message_size: None,
233-
max_frame_size: None,
234-
..Default::default()
231+
let config = {
232+
let mut config = WebSocketConfig::default();
233+
config.max_message_size = None;
234+
config.max_frame_size = None;
235+
236+
config
235237
};
238+
236239
let (stream, _) = connect_async_with_config(url, Some(config), false).await?;
237240

238241
Ok(Self {
@@ -249,7 +252,7 @@ impl WsClient {
249252
};
250253

251254
let json_bytes = match message {
252-
Message::Text(payload) => Cow::Owned(payload.into_bytes()),
255+
Message::Text(payload) => Cow::Owned(payload.as_bytes().to_vec()),
253256
Message::Binary(bytes) => {
254257
let Some(decompressed) = self.compression.inflate(&bytes)? else {
255258
return Ok(None);
@@ -284,7 +287,7 @@ impl WsClient {
284287
}
285288

286289
pub(crate) async fn send_json(&mut self, value: &impl serde::Serialize) -> Result<()> {
287-
let message = serde_json::to_string(value).map(Message::Text)?;
290+
let message = Message::Text(serde_json::to_string(value)?.into());
288291

289292
self.stream.send(message).await?;
290293
Ok(())
@@ -302,7 +305,7 @@ impl WsClient {
302305
}
303306

304307
/// Delegate to `WebSocketStream::close`
305-
pub(crate) async fn close(&mut self, msg: Option<CloseFrame<'_>>) -> Result<()> {
308+
pub(crate) async fn close(&mut self, msg: Option<CloseFrame>) -> Result<()> {
306309
self.stream.close(msg).await?;
307310
Ok(())
308311
}

0 commit comments

Comments
 (0)