diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 3a2cffea52a..00b7de59a70 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -1,6 +1,7 @@ # 0.33.0 [unreleased] - Have methods on `Transport` take `&mut self` instead of `self`. See [PR 2529]. +- Rename `StreamMuxer::close` to `StreamMuxer::poll_close` [PR 2529]: https://github.com/libp2p/rust-libp2p/pull/2529 diff --git a/core/src/either.rs b/core/src/either.rs index df7caf600bd..adeeaa94d15 100644 --- a/core/src/either.rs +++ b/core/src/either.rs @@ -346,10 +346,10 @@ where } } - fn close(&self, cx: &mut Context<'_>) -> Poll> { + fn poll_close(&self, cx: &mut Context<'_>) -> Poll> { match self { - EitherOutput::First(inner) => inner.close(cx).map_err(|e| e.into()), - EitherOutput::Second(inner) => inner.close(cx).map_err(|e| e.into()), + EitherOutput::First(inner) => inner.poll_close(cx).map_err(|e| e.into()), + EitherOutput::Second(inner) => inner.poll_close(cx).map_err(|e| e.into()), } } diff --git a/core/src/muxing.rs b/core/src/muxing.rs index 12beb51d9dd..c6b899d3a20 100644 --- a/core/src/muxing.rs +++ b/core/src/muxing.rs @@ -226,7 +226,7 @@ pub trait StreamMuxer { /// > that the remote is properly informed of the shutdown. However, apart from /// > properly informing the remote, there is no difference between this and /// > immediately dropping the muxer. - fn close(&self, cx: &mut Context<'_>) -> Poll>; + fn poll_close(&self, cx: &mut Context<'_>) -> Poll>; /// Flush this `StreamMuxer`. /// @@ -617,8 +617,8 @@ impl StreamMuxer for StreamMuxerBox { } #[inline] - fn close(&self, cx: &mut Context<'_>) -> Poll> { - self.inner.close(cx) + fn poll_close(&self, cx: &mut Context<'_>) -> Poll> { + self.inner.poll_close(cx) } #[inline] @@ -758,8 +758,8 @@ where } #[inline] - fn close(&self, cx: &mut Context<'_>) -> Poll> { - self.inner.close(cx).map_err(|e| e.into()) + fn poll_close(&self, cx: &mut Context<'_>) -> Poll> { + self.inner.poll_close(cx).map_err(|e| e.into()) } #[inline] diff --git a/core/src/muxing/singleton.rs b/core/src/muxing/singleton.rs index 749e9cd673e..77ab0485ee9 100644 --- a/core/src/muxing/singleton.rs +++ b/core/src/muxing/singleton.rs @@ -149,7 +149,7 @@ where fn destroy_substream(&self, _: Self::Substream) {} - fn close(&self, cx: &mut Context<'_>) -> Poll> { + fn poll_close(&self, cx: &mut Context<'_>) -> Poll> { // The `StreamMuxer` trait requires that `close()` implies `flush_all()`. self.flush_all(cx) } diff --git a/core/tests/util.rs b/core/tests/util.rs index 64e366ecd99..7ca52188a52 100644 --- a/core/tests/util.rs +++ b/core/tests/util.rs @@ -32,7 +32,7 @@ where loop { match std::mem::replace(&mut self.state, CloseMuxerState::Done) { CloseMuxerState::Close(muxer) => { - if !muxer.close(cx)?.is_ready() { + if !muxer.poll_close(cx)?.is_ready() { self.state = CloseMuxerState::Close(muxer); return Poll::Pending; } diff --git a/muxers/mplex/src/lib.rs b/muxers/mplex/src/lib.rs index 0f8598c5eef..78db7218546 100644 --- a/muxers/mplex/src/lib.rs +++ b/muxers/mplex/src/lib.rs @@ -169,7 +169,7 @@ where self.io.lock().drop_stream(sub.id); } - fn close(&self, cx: &mut Context<'_>) -> Poll> { + fn poll_close(&self, cx: &mut Context<'_>) -> Poll> { self.io.lock().poll_close(cx) } diff --git a/muxers/yamux/src/lib.rs b/muxers/yamux/src/lib.rs index 2ce0b065345..b77e3005b6e 100644 --- a/muxers/yamux/src/lib.rs +++ b/muxers/yamux/src/lib.rs @@ -177,7 +177,7 @@ where fn destroy_substream(&self, _: Self::Substream) {} - fn close(&self, c: &mut Context<'_>) -> Poll> { + fn poll_close(&self, c: &mut Context<'_>) -> Poll> { let mut inner = self.0.lock(); if let std::task::Poll::Ready(x) = Pin::new(&mut inner.control).poll_close(c) { return Poll::Ready(x.map_err(YamuxError)); diff --git a/swarm/src/connection/pool.rs b/swarm/src/connection/pool.rs index 6c0c3840c08..8186154c9b3 100644 --- a/swarm/src/connection/pool.rs +++ b/swarm/src/connection/pool.rs @@ -686,7 +686,7 @@ where if let Err(error) = error { self.spawn( poll_fn(move |cx| { - if let Err(e) = ready!(muxer.close(cx)) { + if let Err(e) = ready!(muxer.poll_close(cx)) { log::debug!( "Failed to close connection {:?} to peer {}: {:?}", id, diff --git a/swarm/src/connection/substream.rs b/swarm/src/connection/substream.rs index 426f64d9f60..ba83a67e46a 100644 --- a/swarm/src/connection/substream.rs +++ b/swarm/src/connection/substream.rs @@ -211,7 +211,7 @@ where type Output = Result<(), IoError>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - match self.muxer.close(cx) { + match self.muxer.poll_close(cx) { Poll::Pending => Poll::Pending, Poll::Ready(Ok(())) => Poll::Ready(Ok(())), Poll::Ready(Err(err)) => Poll::Ready(Err(err.into())),