From f2e4dcd0b9e8297ce2ba371538ea5ab289740382 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Sun, 15 May 2022 22:17:35 +1000 Subject: [PATCH] Rename `close` to `poll_close` It is common practise to prefix functions that return a `Poll` with `poll_`. --- core/CHANGELOG.md | 1 + core/src/either.rs | 6 +++--- core/src/muxing.rs | 10 +++++----- core/src/muxing/singleton.rs | 2 +- muxers/mplex/src/lib.rs | 2 +- muxers/yamux/src/lib.rs | 2 +- swarm/src/connection/pool.rs | 2 +- swarm/src/connection/substream.rs | 2 +- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 3a2cffea52a3..00b7de59a70d 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 df7caf600bd0..adeeaa94d15b 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 12beb51d9dd5..c6b899d3a205 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 749e9cd673ef..77ab0485ee9c 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/muxers/mplex/src/lib.rs b/muxers/mplex/src/lib.rs index 0f8598c5eef4..78db72185462 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 2ce0b0653452..b77e3005b6e4 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 6c0c3840c089..8186154c9b39 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 426f64d9f606..ba83a67e46aa 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())),