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