//! Unix-specific extensions to primitives in the `tokio_fs` module. use std::io; use std::path::Path; use std::os::unix::fs; use futures::{Future, Poll}; /// Creates a new symbolic link on the filesystem. /// /// The `dst` path will be a symbolic link pointing to the `src` path. /// /// This is an async version of [`std::os::unix::fs::symlink`][std] /// /// [std]: https://doc.rust-lang.org/std/os/unix/fs/fn.symlink.html pub fn symlink, Q: AsRef>(src: P, dst: Q) -> SymlinkFuture { SymlinkFuture::new(src, dst) } /// Future returned by `symlink`. #[derive(Debug)] pub struct SymlinkFuture where P: AsRef, Q: AsRef { src: P, dst: Q, } impl SymlinkFuture where P: AsRef, Q: AsRef { fn new(src: P, dst: Q) -> SymlinkFuture { SymlinkFuture { src: src, dst: dst, } } } impl Future for SymlinkFuture where P: AsRef, Q: AsRef { type Item = (); type Error = io::Error; fn poll(&mut self) -> Poll { ::blocking_io(|| fs::symlink(&self.src, &self.dst) ) } }