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