[−][src]Function async_std::fs::copy
pub async fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<u64>
Copies the contents and permissions of one file to another.
On success, the total number of bytes copied is returned and equals the length of the from
file.
The old contents of to will be overwritten. If from and to both point to the same file,
then the file will likely get truncated by this operation.
This function is an async version of std::fs::copy.
Errors
An error will be returned in the following situations (not an exhaustive list):
- The
frompath is not a file. - The
fromfile does not exist. - The current process lacks permissions to access
fromor writeto.
Examples
use async_std::fs; let bytes_copied = fs::copy("a.txt", "b.txt").await?;