1 use crate::fs::asyncify;
2 use std::path::Path;
3 
4 /// Copies the contents of one file to another. This function will also copy the permission bits of the original file to the destination file.
5 /// This function will overwrite the contents of to.
6 ///
7 /// This is the async equivalent of `std::fs::copy`.
8 ///
9 /// # Examples
10 ///
11 /// ```no_run
12 /// use tokio::fs;
13 ///
14 /// # async fn dox() -> std::io::Result<()> {
15 /// fs::copy("foo.txt", "bar.txt").await?;
16 /// # Ok(())
17 /// # }
18 /// ```
19 
copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<u64, std::io::Error>20 pub async fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<u64, std::io::Error> {
21     let from = from.as_ref().to_owned();
22     let to = to.as_ref().to_owned();
23     asyncify(|| std::fs::copy(from, to)).await
24 }
25