2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-04-08 09:26:42 +00:00

Fix vectored IO for TcpStream

Implements `Write::poll_write_vectored` and `Read::poll_read_vectored`
on `TcpStream` using the vectored IO methods on the underlying stream.
Previously, the trait's default implementation was used, which just
called `poll_write` and `poll_read` once for each `IoSlice`.
This commit is contained in:
Theo Bogusta 2021-01-19 14:28:35 -05:00
parent 6278fdc724
commit a46464deab

View file

@ -307,6 +307,14 @@ impl Read for &TcpStream {
) -> Poll<io::Result<usize>> {
Pin::new(&mut &*self.watcher).poll_read(cx, buf)
}
fn poll_read_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>],
) -> Poll<io::Result<usize>> {
Pin::new(&mut &*self.watcher).poll_read_vectored(cx, bufs)
}
}
impl Write for TcpStream {
@ -344,6 +352,14 @@ impl Write for &TcpStream {
Pin::new(&mut &*self.watcher).poll_write(cx, buf)
}
fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<io::Result<usize>> {
Pin::new(&mut &*self.watcher).poll_write_vectored(cx, bufs)
}
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
Pin::new(&mut &*self.watcher).poll_flush(cx)
}