Coverage Report

Created: 2025-07-11 06:53

/rust/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.46.1/src/fs/copy.rs
Line
Count
Source (jump to first uncovered line)
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
5
/// of the original file to the destination file.
6
/// This function will overwrite the contents of to.
7
///
8
/// This is the async equivalent of [`std::fs::copy`].
9
///
10
/// # Examples
11
///
12
/// ```no_run
13
/// use tokio::fs;
14
///
15
/// # async fn dox() -> std::io::Result<()> {
16
/// fs::copy("foo.txt", "bar.txt").await?;
17
/// # Ok(())
18
/// # }
19
/// ```
20
21
0
pub async fn copy(from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<u64, std::io::Error> {
22
0
    let from = from.as_ref().to_owned();
23
0
    let to = to.as_ref().to_owned();
24
0
    asyncify(|| std::fs::copy(from, to)).await
25
0
}