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