core/muxing: Remove the StreamMuxer::flush_all function (#2669)

`libp2p-core` provides the `StreamMuxer` abstraction so it can provide
functionality that abstracts over this trait.

We never use the `flush_all` function as part of our abstractions.
No one else is going to use it so we can remove it from the abstraction.
This commit is contained in:
Thomas Eizinger
2022-05-29 17:23:13 +02:00
committed by GitHub
parent 25c8bc24de
commit 2b79f113bb
6 changed files with 5 additions and 39 deletions

View File

@ -352,13 +352,6 @@ where
EitherOutput::Second(inner) => inner.poll_close(cx).map_err(|e| e.into()),
}
}
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
match self {
EitherOutput::First(inner) => inner.flush_all(cx).map_err(|e| e.into()),
EitherOutput::Second(inner) => inner.flush_all(cx).map_err(|e| e.into()),
}
}
}
#[derive(Debug, Copy, Clone)]

View File

@ -216,13 +216,6 @@ pub trait StreamMuxer {
/// > properly informing the remote, there is no difference between this and
/// > immediately dropping the muxer.
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
/// Flush this `StreamMuxer`.
///
/// This drains any write buffers of substreams and delivers any pending shutdown notifications
/// due to `shutdown_substream` or `close`. One may thus shutdown groups of substreams
/// followed by a final `flush_all` instead of having to do `flush_substream` for each.
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
}
/// Event about a connection, reported by an implementation of [`StreamMuxer`].
@ -609,11 +602,6 @@ impl StreamMuxer for StreamMuxerBox {
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.inner.poll_close(cx)
}
#[inline]
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.inner.flush_all(cx)
}
}
struct Wrap<T>
@ -750,9 +738,4 @@ where
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.inner.poll_close(cx).map_err(|e| e.into())
}
#[inline]
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.inner.flush_all(cx).map_err(|e| e.into())
}
}

View File

@ -149,12 +149,7 @@ where
fn destroy_substream(&self, _: Self::Substream) {}
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
// The `StreamMuxer` trait requires that `close()` implies `flush_all()`.
self.flush_all(cx)
}
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
AsyncWrite::poll_flush(Pin::new(&mut *self.inner.lock()), cx)
fn poll_close(&self, _cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
Poll::Ready(Ok(()))
}
}