1use std::fs;
2use std::io;
3use std::path::Path;
4
5use futures::{Future, Poll};
6
7pub fn create_dir<P: AsRef<Path>>(path: P) -> CreateDirFuture<P> {
13 CreateDirFuture::new(path)
14}
15
16#[derive(Debug)]
18pub struct CreateDirFuture<P>
19where
20 P: AsRef<Path>,
21{
22 path: P,
23}
24
25impl<P> CreateDirFuture<P>
26where
27 P: AsRef<Path>,
28{
29 fn new(path: P) -> CreateDirFuture<P> {
30 CreateDirFuture { path: path }
31 }
32}
33
34impl<P> Future for CreateDirFuture<P>
35where
36 P: AsRef<Path>,
37{
38 type Item = ();
39 type Error = io::Error;
40
41 fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
42 ::blocking_io(|| fs::create_dir(&self.path))
43 }
44}