Prepare update to tungstenite 0.20

tungstenite-0.20
Alex Butler 1 year ago committed by Sebastian Dröge
parent 17866906ea
commit b3376f3dd9
  1. 2
      Cargo.toml
  2. 12
      src/lib.rs

@ -41,7 +41,7 @@ futures-io = { version = "0.3", default-features = false, features = ["std"] }
pin-project-lite = "0.2" pin-project-lite = "0.2"
[dependencies.tungstenite] [dependencies.tungstenite]
version = "0.19" version = "0.20"
default-features = false default-features = false
[dependencies.async-std] [dependencies.async-std]

@ -334,11 +334,11 @@ where
match futures_util::ready!(self.with_context(Some((ContextWaker::Read, cx)), |s| { match futures_util::ready!(self.with_context(Some((ContextWaker::Read, cx)), |s| {
#[cfg(feature = "verbose-logging")] #[cfg(feature = "verbose-logging")]
trace!( trace!(
"{}:{} Stream.with_context poll_next -> read_message()", "{}:{} Stream.with_context poll_next -> read()",
file!(), file!(),
line!() line!()
); );
cvt(s.read_message()) cvt(s.read())
})) { })) {
Ok(v) => Poll::Ready(Some(Ok(v))), Ok(v) => Poll::Ready(Some(Ok(v))),
Err(e) => { Err(e) => {
@ -373,7 +373,7 @@ where
} }
fn start_send(mut self: Pin<&mut Self>, item: Message) -> Result<(), Self::Error> { 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(()), Ok(()) => Ok(()),
Err(WsError::Io(err)) if err.kind() == std::io::ErrorKind::WouldBlock => { Err(WsError::Io(err)) if err.kind() == std::io::ErrorKind::WouldBlock => {
// the message was accepted and queued // the message was accepted and queued
@ -388,7 +388,7 @@ where
} }
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
(*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. // WebSocket connection has just been closed. Flushing completed, not an error.
match r { match r {
Err(WsError::ConnectionClosed) => Ok(()), Err(WsError::ConnectionClosed) => Ok(()),
@ -399,8 +399,8 @@ where
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
let res = if self.closing { let res = if self.closing {
// After queueing it, we call `write_pending` to drive the close handshake to completion. // After queueing it, we call `flush` to drive the close handshake to completion.
(*self).with_context(Some((ContextWaker::Write, cx)), |s| s.write_pending()) (*self).with_context(Some((ContextWaker::Write, cx)), |s| s.flush())
} else { } else {
(*self).with_context(Some((ContextWaker::Write, cx)), |s| s.close(None)) (*self).with_context(Some((ContextWaker::Write, cx)), |s| s.close(None))
}; };

Loading…
Cancel
Save