From e9ae5d4ce993d8c8611b86065f1fe26188fff0ca Mon Sep 17 00:00:00 2001 From: Bharath Vedartham Date: Tue, 2 Apr 2024 16:30:44 +0530 Subject: [PATCH] io: implement `AsyncBufRead` for `Join` (#6449) Fixes: #6446 --- tokio/src/io/join.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tokio/src/io/join.rs b/tokio/src/io/join.rs index dbc7043b6..6e41f89e8 100644 --- a/tokio/src/io/join.rs +++ b/tokio/src/io/join.rs @@ -1,6 +1,6 @@ //! Join two values implementing `AsyncRead` and `AsyncWrite` into a single one. -use crate::io::{AsyncRead, AsyncWrite, ReadBuf}; +use crate::io::{AsyncBufRead, AsyncRead, AsyncWrite, ReadBuf}; use std::io; use std::pin::Pin; @@ -115,3 +115,16 @@ where self.writer.is_write_vectored() } } + +impl AsyncBufRead for Join +where + R: AsyncBufRead, +{ + fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + self.project().reader.poll_fill_buf(cx) + } + + fn consume(self: Pin<&mut Self>, amt: usize) { + self.project().reader.consume(amt) + } +}