Coverage Report

Created: 2026-09-28 07:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.53.1/src/fs/rename.rs
Line
Count
Source
1
use crate::fs::asyncify;
2
3
use std::io;
4
use std::path::Path;
5
6
/// Renames a file or directory to a new name, replacing the original file if
7
/// `to` already exists.
8
///
9
/// This will not work if the new name is on a different mount point.
10
///
11
/// This is an async version of [`std::fs::rename`].
12
661
pub async fn rename(from: impl AsRef<Path>, to: impl AsRef<Path>) -> io::Result<()> {
tokio::fs::rename::rename::<std::path::PathBuf, std::path::PathBuf>
Line
Count
Source
12
661
pub async fn rename(from: impl AsRef<Path>, to: impl AsRef<Path>) -> io::Result<()> {
Unexecuted instantiation: tokio::fs::rename::rename::<&std::path::PathBuf, &std::path::PathBuf>
Unexecuted instantiation: tokio::fs::rename::rename::<_, _>
13
661
    let from = from.as_ref();
14
661
    let to = to.as_ref();
15
16
    #[cfg(all(
17
        tokio_unstable,
18
        feature = "io-uring",
19
        feature = "rt",
20
        feature = "fs",
21
        target_os = "linux",
22
    ))]
23
    {
24
        use crate::io::uring::rename::Rename;
25
        use crate::runtime::driver::op::Op;
26
27
        let handle = crate::runtime::Handle::current();
28
        let driver_handle = handle.inner.driver().io();
29
30
        type RenameOp = Op<Rename>;
31
32
        if driver_handle
33
            .check_and_init(io_uring::opcode::RenameAt::CODE)
34
            .await?
35
        {
36
            return RenameOp::rename(from, to)?.await;
37
        }
38
    }
39
40
661
    rename_blocking(from, to).await
41
661
}
tokio::fs::rename::rename::<std::path::PathBuf, std::path::PathBuf>::{closure#0}
Line
Count
Source
12
661
pub async fn rename(from: impl AsRef<Path>, to: impl AsRef<Path>) -> io::Result<()> {
13
661
    let from = from.as_ref();
14
661
    let to = to.as_ref();
15
16
    #[cfg(all(
17
        tokio_unstable,
18
        feature = "io-uring",
19
        feature = "rt",
20
        feature = "fs",
21
        target_os = "linux",
22
    ))]
23
    {
24
        use crate::io::uring::rename::Rename;
25
        use crate::runtime::driver::op::Op;
26
27
        let handle = crate::runtime::Handle::current();
28
        let driver_handle = handle.inner.driver().io();
29
30
        type RenameOp = Op<Rename>;
31
32
        if driver_handle
33
            .check_and_init(io_uring::opcode::RenameAt::CODE)
34
            .await?
35
        {
36
            return RenameOp::rename(from, to)?.await;
37
        }
38
    }
39
40
661
    rename_blocking(from, to).await
41
661
}
Unexecuted instantiation: tokio::fs::rename::rename::<&std::path::PathBuf, &std::path::PathBuf>::{closure#0}
Unexecuted instantiation: tokio::fs::rename::rename::<_, _>::{closure#0}
42
43
661
async fn rename_blocking(from: &Path, to: &Path) -> io::Result<()> {
44
661
    let [from, to] = [from, to].map(Path::to_owned);
45
661
    asyncify(move || std::fs::rename(from, to)).await
tokio::fs::rename::rename_blocking::{closure#0}::{closure#0}
Line
Count
Source
45
661
    asyncify(move || std::fs::rename(from, to)).await
Unexecuted instantiation: tokio::fs::rename::rename_blocking::{closure#0}::{closure#0}
46
661
}
tokio::fs::rename::rename_blocking::{closure#0}
Line
Count
Source
43
661
async fn rename_blocking(from: &Path, to: &Path) -> io::Result<()> {
44
661
    let [from, to] = [from, to].map(Path::to_owned);
45
661
    asyncify(move || std::fs::rename(from, to)).await
46
661
}
Unexecuted instantiation: tokio::fs::rename::rename_blocking::{closure#0}