Merge pull request #27 from stjepang/feat/vectored

feat(async_io): support vectored methods
This commit is contained in:
Stjepan Glavina 2020-04-26 13:17:48 -07:00 committed by GitHub
commit 8293817139
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 1 deletions

View File

@ -5,7 +5,7 @@
//! [wepoll]: https://github.com/piscisaureus/wepoll
use std::future::Future;
use std::io::{self, Read, Write};
use std::io::{self, IoSlice, IoSliceMut, Read, Write};
use std::net::{SocketAddr, TcpListener, TcpStream, ToSocketAddrs, UdpSocket};
#[cfg(windows)]
use std::os::windows::io::{AsRawSocket, IntoRawSocket, RawSocket};
@ -358,6 +358,14 @@ impl<T: Read> AsyncRead for Async<T> {
) -> Poll<io::Result<usize>> {
poll_future(cx, self.with_mut(|io| io.read(buf)))
}
fn poll_read_vectored(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>],
) -> Poll<io::Result<usize>> {
poll_future(cx, self.with_mut(|io| io.read_vectored(bufs)))
}
}
impl<T> AsyncRead for &Async<T>
@ -371,6 +379,14 @@ where
) -> Poll<io::Result<usize>> {
poll_future(cx, self.with(|io| (&*io).read(buf)))
}
fn poll_read_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>],
) -> Poll<io::Result<usize>> {
poll_future(cx, self.with(|io| (&*io).read_vectored(bufs)))
}
}
impl<T: Write> AsyncWrite for Async<T> {
@ -382,6 +398,14 @@ impl<T: Write> AsyncWrite for Async<T> {
poll_future(cx, self.with_mut(|io| io.write(buf)))
}
fn poll_write_vectored(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<io::Result<usize>> {
poll_future(cx, self.with_mut(|io| io.write_vectored(bufs)))
}
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
poll_future(cx, self.with_mut(|io| io.flush()))
}
@ -403,6 +427,14 @@ where
poll_future(cx, self.with(|io| (&*io).write(buf)))
}
fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<io::Result<usize>> {
poll_future(cx, self.with(|io| (&*io).write_vectored(bufs)))
}
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
poll_future(cx, self.with(|io| (&*io).flush()))
}