Skip to content

Commit 25c8bc2

Browse files
core/muxing: Rename close to poll_close (#2666)
It is common practise to prefix functions that return a `Poll` with `poll_`.
1 parent 8361fab commit 25c8bc2

File tree

9 files changed

+16
-14
lines changed

9 files changed

+16
-14
lines changed

core/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# 0.33.0 [unreleased]
22

33
- Have methods on `Transport` take `&mut self` instead of `self`. See [PR 2529].
4+
- Rename `StreamMuxer::close` to `StreamMuxer::poll_close`. See [PR 2666].
45
- Remove deprecated function `StreamMuxer::is_remote_acknowledged`. See [PR 2665].
56

67
[PR 2529]: https://github.com/libp2p/rust-libp2p/pull/2529
8+
[PR 2666]: https://github.com/libp2p/rust-libp2p/pull/2666
79
[PR 2665]: https://github.com/libp2p/rust-libp2p/pull/2665
810

911
# 0.32.1

core/src/either.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,10 @@ where
346346
}
347347
}
348348

349-
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
349+
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
350350
match self {
351-
EitherOutput::First(inner) => inner.close(cx).map_err(|e| e.into()),
352-
EitherOutput::Second(inner) => inner.close(cx).map_err(|e| e.into()),
351+
EitherOutput::First(inner) => inner.poll_close(cx).map_err(|e| e.into()),
352+
EitherOutput::Second(inner) => inner.poll_close(cx).map_err(|e| e.into()),
353353
}
354354
}
355355

core/src/muxing.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ pub trait StreamMuxer {
215215
/// > that the remote is properly informed of the shutdown. However, apart from
216216
/// > properly informing the remote, there is no difference between this and
217217
/// > immediately dropping the muxer.
218-
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
218+
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
219219

220220
/// Flush this `StreamMuxer`.
221221
///
@@ -606,8 +606,8 @@ impl StreamMuxer for StreamMuxerBox {
606606
}
607607

608608
#[inline]
609-
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
610-
self.inner.close(cx)
609+
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
610+
self.inner.poll_close(cx)
611611
}
612612

613613
#[inline]
@@ -747,8 +747,8 @@ where
747747
}
748748

749749
#[inline]
750-
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
751-
self.inner.close(cx).map_err(|e| e.into())
750+
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
751+
self.inner.poll_close(cx).map_err(|e| e.into())
752752
}
753753

754754
#[inline]

core/src/muxing/singleton.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ where
149149

150150
fn destroy_substream(&self, _: Self::Substream) {}
151151

152-
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
152+
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
153153
// The `StreamMuxer` trait requires that `close()` implies `flush_all()`.
154154
self.flush_all(cx)
155155
}

core/tests/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ where
3232
loop {
3333
match std::mem::replace(&mut self.state, CloseMuxerState::Done) {
3434
CloseMuxerState::Close(muxer) => {
35-
if !muxer.close(cx)?.is_ready() {
35+
if !muxer.poll_close(cx)?.is_ready() {
3636
self.state = CloseMuxerState::Close(muxer);
3737
return Poll::Pending;
3838
}

muxers/mplex/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ where
169169
self.io.lock().drop_stream(sub.id);
170170
}
171171

172-
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
172+
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
173173
self.io.lock().poll_close(cx)
174174
}
175175

muxers/yamux/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ where
177177

178178
fn destroy_substream(&self, _: Self::Substream) {}
179179

180-
fn close(&self, c: &mut Context<'_>) -> Poll<YamuxResult<()>> {
180+
fn poll_close(&self, c: &mut Context<'_>) -> Poll<YamuxResult<()>> {
181181
let mut inner = self.0.lock();
182182
if let std::task::Poll::Ready(x) = Pin::new(&mut inner.control).poll_close(c) {
183183
return Poll::Ready(x.map_err(YamuxError));

swarm/src/connection/pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ where
686686
if let Err(error) = error {
687687
self.spawn(
688688
poll_fn(move |cx| {
689-
if let Err(e) = ready!(muxer.close(cx)) {
689+
if let Err(e) = ready!(muxer.poll_close(cx)) {
690690
log::debug!(
691691
"Failed to close connection {:?} to peer {}: {:?}",
692692
id,

swarm/src/connection/substream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ where
211211
type Output = Result<(), IoError>;
212212

213213
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
214-
match self.muxer.close(cx) {
214+
match self.muxer.poll_close(cx) {
215215
Poll::Pending => Poll::Pending,
216216
Poll::Ready(Ok(())) => Poll::Ready(Ok(())),
217217
Poll::Ready(Err(err)) => Poll::Ready(Err(err.into())),

0 commit comments

Comments
 (0)