From 79a2afae9ff870a8e49e25e360ff77d9b1cdacad Mon Sep 17 00:00:00 2001 From: Motoyuki Kimura Date: Tue, 10 Dec 2024 01:52:16 +0900 Subject: [PATCH] util: enable `Either` to use underlying `AsyncWrite` implementation (#7025) --- tokio-util/src/either.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tokio-util/src/either.rs b/tokio-util/src/either.rs index e7fec9546b3..f661bb9e11d 100644 --- a/tokio-util/src/either.rs +++ b/tokio-util/src/either.rs @@ -150,6 +150,21 @@ where fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { delegate_call!(self.poll_shutdown(cx)) } + + fn poll_write_vectored( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + bufs: &[std::io::IoSlice<'_>], + ) -> Poll> { + delegate_call!(self.poll_write_vectored(cx, bufs)) + } + + fn is_write_vectored(&self) -> bool { + match self { + Self::Left(l) => l.is_write_vectored(), + Self::Right(r) => r.is_write_vectored(), + } + } } impl futures_core::stream::Stream for Either