core/muxing: Rename close to poll_close (#2666)

It is common practise to prefix functions that return a `Poll` with
`poll_`.
This commit is contained in:
Thomas Eizinger 2022-05-29 16:27:40 +02:00 committed by GitHub
parent 8361fabb47
commit 25c8bc24de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 16 additions and 14 deletions

View File

@ -1,9 +1,11 @@
# 0.33.0 [unreleased]
- Have methods on `Transport` take `&mut self` instead of `self`. See [PR 2529].
- Rename `StreamMuxer::close` to `StreamMuxer::poll_close`. See [PR 2666].
- Remove deprecated function `StreamMuxer::is_remote_acknowledged`. See [PR 2665].
[PR 2529]: https://github.com/libp2p/rust-libp2p/pull/2529
[PR 2666]: https://github.com/libp2p/rust-libp2p/pull/2666
[PR 2665]: https://github.com/libp2p/rust-libp2p/pull/2665
# 0.32.1

View File

@ -346,10 +346,10 @@ where
}
}
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
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()),
}
}

View File

@ -215,7 +215,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<Result<(), Self::Error>>;
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
/// Flush this `StreamMuxer`.
///
@ -606,8 +606,8 @@ impl StreamMuxer for StreamMuxerBox {
}
#[inline]
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.inner.close(cx)
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.inner.poll_close(cx)
}
#[inline]
@ -747,8 +747,8 @@ where
}
#[inline]
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.inner.close(cx).map_err(|e| e.into())
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.inner.poll_close(cx).map_err(|e| e.into())
}
#[inline]

View File

@ -149,7 +149,7 @@ where
fn destroy_substream(&self, _: Self::Substream) {}
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
// The `StreamMuxer` trait requires that `close()` implies `flush_all()`.
self.flush_all(cx)
}

View File

@ -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;
}

View File

@ -169,7 +169,7 @@ where
self.io.lock().drop_stream(sub.id);
}
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
self.io.lock().poll_close(cx)
}

View File

@ -177,7 +177,7 @@ where
fn destroy_substream(&self, _: Self::Substream) {}
fn close(&self, c: &mut Context<'_>) -> Poll<YamuxResult<()>> {
fn poll_close(&self, c: &mut Context<'_>) -> Poll<YamuxResult<()>> {
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));

View File

@ -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,

View File

@ -211,7 +211,7 @@ where
type Output = Result<(), IoError>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
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())),