From b3376f3dd9b1ca0eb7cec51839e52e0f2e83e443 Mon Sep 17 00:00:00 2001 From: Alex Butler Date: Sun, 28 May 2023 19:29:31 +0100 Subject: [PATCH] Prepare update to tungstenite 0.20 --- Cargo.toml | 2 +- src/lib.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fa51f66..9054c35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ futures-io = { version = "0.3", default-features = false, features = ["std"] } pin-project-lite = "0.2" [dependencies.tungstenite] -version = "0.19" +version = "0.20" default-features = false [dependencies.async-std] diff --git a/src/lib.rs b/src/lib.rs index 6c36737..83ae537 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -334,11 +334,11 @@ where match futures_util::ready!(self.with_context(Some((ContextWaker::Read, cx)), |s| { #[cfg(feature = "verbose-logging")] trace!( - "{}:{} Stream.with_context poll_next -> read_message()", + "{}:{} Stream.with_context poll_next -> read()", file!(), line!() ); - cvt(s.read_message()) + cvt(s.read()) })) { Ok(v) => Poll::Ready(Some(Ok(v))), Err(e) => { @@ -373,7 +373,7 @@ where } fn start_send(mut self: Pin<&mut Self>, item: Message) -> Result<(), Self::Error> { - match (*self).with_context(None, |s| s.write_message(item)) { + match (*self).with_context(None, |s| s.write(item)) { Ok(()) => Ok(()), Err(WsError::Io(err)) if err.kind() == std::io::ErrorKind::WouldBlock => { // the message was accepted and queued @@ -388,7 +388,7 @@ where } fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - (*self).with_context(Some((ContextWaker::Write, cx)), |s| cvt(s.write_pending())).map(|r| { + (*self).with_context(Some((ContextWaker::Write, cx)), |s| cvt(s.flush())).map(|r| { // WebSocket connection has just been closed. Flushing completed, not an error. match r { Err(WsError::ConnectionClosed) => Ok(()), @@ -399,8 +399,8 @@ where fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { let res = if self.closing { - // After queueing it, we call `write_pending` to drive the close handshake to completion. - (*self).with_context(Some((ContextWaker::Write, cx)), |s| s.write_pending()) + // After queueing it, we call `flush` to drive the close handshake to completion. + (*self).with_context(Some((ContextWaker::Write, cx)), |s| s.flush()) } else { (*self).with_context(Some((ContextWaker::Write, cx)), |s| s.close(None)) };