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
+6 -4
View File
@@ -1,7 +1,10 @@
use futures::{Future, Poll};
use std::fs;
use std::future::Future;
use std::io;
use std::path::Path;
use std::pin::Pin;
use std::task::Context;
use std::task::Poll;
/// Recursively create a directory and all of its parent components if they
/// are missing.
@@ -35,10 +38,9 @@ impl<P> Future for CreateDirAllFuture<P>
where
P: AsRef<Path>,
{
type Item = ();
type Error = io::Error;
type Output = io::Result<()>;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> {
crate::blocking_io(|| fs::create_dir_all(&self.path))
}
}