fs: update to use std::future (#1269)

This commit is contained in:
andy finch
2019-07-11 09:05:49 -07:00
committed by Carl Lerche
parent 7ac8bfc821
commit 795e02f4c6
36 changed files with 492 additions and 305 deletions
+12 -2
View File
@@ -1,4 +1,7 @@
use std::io::{self, Read, Stdin as StdStdin};
use std::pin::Pin;
use std::task::Context;
use std::task::Poll;
use tokio_io::AsyncRead;
/// A handle to the standard input stream of a process.
@@ -37,7 +40,14 @@ impl Read for Stdin {
}
impl AsyncRead for Stdin {
unsafe fn prepare_uninitialized_buffer(&self, _: &mut [u8]) -> bool {
false
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<io::Result<usize>> {
match Pin::get_mut(self).read(buf) {
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => Poll::Pending,
other => Poll::Ready(other),
}
}
}