diff options
Diffstat (limited to 'src/io/stream_reader.rs')
-rw-r--r-- | src/io/stream_reader.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/io/stream_reader.rs b/src/io/stream_reader.rs index 3353722..6ecf8ec 100644 --- a/src/io/stream_reader.rs +++ b/src/io/stream_reader.rs @@ -1,5 +1,6 @@ use bytes::Buf; use futures_core::stream::Stream; +use futures_sink::Sink; use std::io; use std::pin::Pin; use std::task::{Context, Poll}; @@ -165,7 +166,7 @@ where B: Buf, E: Into<std::io::Error>, { - /// Convert a stream of byte chunks into an [`AsyncRead`](tokio::io::AsyncRead). + /// Convert a stream of byte chunks into an [`AsyncRead`]. /// /// The item should be a [`Result`] with the ok variant being something that /// implements the [`Buf`] trait (e.g. `Vec<u8>` or `Bytes`). The error @@ -324,3 +325,22 @@ impl<S, B> StreamReader<S, B> { } } } + +impl<S: Sink<T, Error = E>, E, T> Sink<T> for StreamReader<S, E> { + type Error = E; + fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { + self.project().inner.poll_ready(cx) + } + + fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), Self::Error> { + self.project().inner.start_send(item) + } + + fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { + self.project().inner.poll_flush(cx) + } + + fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { + self.project().inner.poll_close(cx) + } +} |