tokio_fs/
symlink_metadata.rs

1use super::blocking_io;
2
3use futures::{Future, Poll};
4
5use std::fs::{self, Metadata};
6use std::io;
7use std::path::Path;
8
9/// Queries the file system metadata for a path.
10///
11/// This is an async version of [`std::fs::symlink_metadata`][std]
12///
13/// [std]: https://doc.rust-lang.org/std/fs/fn.symlink_metadata.html
14pub fn symlink_metadata<P>(path: P) -> SymlinkMetadataFuture<P>
15where
16    P: AsRef<Path> + Send + 'static,
17{
18    SymlinkMetadataFuture::new(path)
19}
20
21/// Future returned by `symlink_metadata`.
22#[derive(Debug)]
23pub struct SymlinkMetadataFuture<P>
24where
25    P: AsRef<Path> + Send + 'static,
26{
27    path: P,
28}
29
30impl<P> SymlinkMetadataFuture<P>
31where
32    P: AsRef<Path> + Send + 'static,
33{
34    pub(crate) fn new(path: P) -> Self {
35        Self { path }
36    }
37}
38
39impl<P> Future for SymlinkMetadataFuture<P>
40where
41    P: AsRef<Path> + Send + 'static,
42{
43    type Item = Metadata;
44    type Error = io::Error;
45
46    fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
47        blocking_io(|| fs::symlink_metadata(&self.path))
48    }
49}