1use super::File;
2
3use futures::{Future, Poll};
4
5use std::fs::File as StdFile;
6use std::io;
7use std::path::Path;
8
9#[derive(Debug)]
11pub struct CreateFuture<P> {
12 path: P,
13}
14
15impl<P> CreateFuture<P>
16where
17 P: AsRef<Path> + Send + 'static,
18{
19 pub(crate) fn new(path: P) -> Self {
20 CreateFuture { path }
21 }
22}
23
24impl<P> Future for CreateFuture<P>
25where
26 P: AsRef<Path> + Send + 'static,
27{
28 type Item = File;
29 type Error = io::Error;
30
31 fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
32 let std = try_ready!(::blocking_io(|| StdFile::create(&self.path)));
33
34 let file = File::from_std(std);
35 Ok(file.into())
36 }
37}