Coverage Report

Created: 2025-02-21 07:11

/rust/registry/src/index.crates.io-6f17d22bba15001f/tempfile-3.16.0/src/error.rs
Line
Count
Source (jump to first uncovered line)
1
use std::path::PathBuf;
2
use std::{error, fmt, io};
3
4
#[derive(Debug)]
5
struct PathError {
6
    path: PathBuf,
7
    err: io::Error,
8
}
9
10
impl fmt::Display for PathError {
11
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
12
0
        write!(f, "{} at path {:?}", self.err, self.path)
13
0
    }
14
}
15
16
impl error::Error for PathError {
17
0
    fn source(&self) -> Option<&(dyn error::Error + 'static)> {
18
0
        self.err.source()
19
0
    }
20
}
21
22
pub(crate) trait IoResultExt<T> {
23
    fn with_err_path<F, P>(self, path: F) -> Self
24
    where
25
        F: FnOnce() -> P,
26
        P: Into<PathBuf>;
27
}
28
29
impl<T> IoResultExt<T> for Result<T, io::Error> {
30
0
    fn with_err_path<F, P>(self, path: F) -> Self
31
0
    where
32
0
        F: FnOnce() -> P,
33
0
        P: Into<PathBuf>,
34
0
    {
35
0
        self.map_err(|e| {
36
0
            io::Error::new(
37
0
                e.kind(),
38
0
                PathError {
39
0
                    path: path().into(),
40
0
                    err: e,
41
0
                },
42
0
            )
43
0
        })
Unexecuted instantiation: <core::result::Result<tempfile::dir::TempDir, std::io::error::Error> as tempfile::error::IoResultExt<tempfile::dir::TempDir>>::with_err_path::<tempfile::util::create_helper<tempfile::dir::TempDir, <tempfile::Builder>::tempdir_in<&std::path::Path>::{closure#0}>::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<tempfile::dir::TempDir, std::io::error::Error> as tempfile::error::IoResultExt<tempfile::dir::TempDir>>::with_err_path::<tempfile::util::create_helper<tempfile::dir::TempDir, <tempfile::Builder>::tempdir_in<std::path::PathBuf>::{closure#0}>::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<tempfile::file::NamedTempFile, std::io::error::Error> as tempfile::error::IoResultExt<tempfile::file::NamedTempFile>>::with_err_path::<tempfile::util::create_helper<tempfile::file::NamedTempFile, <tempfile::Builder>::tempfile_in<std::path::PathBuf>::{closure#0}>::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<std::fs::File, std::io::error::Error> as tempfile::error::IoResultExt<std::fs::File>>::with_err_path::<tempfile::util::create_helper<std::fs::File, tempfile::file::imp::unix::create_unix::{closure#0}>::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<std::fs::File, std::io::error::Error> as tempfile::error::IoResultExt<std::fs::File>>::with_err_path::<<tempfile::file::NamedTempFile>::reopen::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<std::fs::File, std::io::error::Error> as tempfile::error::IoResultExt<std::fs::File>>::with_err_path::<tempfile::file::create_named::{closure#0}, std::path::PathBuf>::{closure#0}
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_to_end::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_vectored::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_to_string::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write_vectored::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<tempfile::dir::TempDir>::close::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<tempfile::file::TempPath>::close::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<tempfile::dir::imp::unix::create::{closure#0}, &std::path::PathBuf>::{closure#0}
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_exact::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write_all::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write_fmt::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<u64, std::io::error::Error> as tempfile::error::IoResultExt<u64>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Seek>::seek::{closure#0}, &std::path::Path>::{closure#0}
44
0
    }
Unexecuted instantiation: <core::result::Result<tempfile::dir::TempDir, std::io::error::Error> as tempfile::error::IoResultExt<tempfile::dir::TempDir>>::with_err_path::<tempfile::util::create_helper<tempfile::dir::TempDir, <tempfile::Builder>::tempdir_in<&std::path::Path>::{closure#0}>::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<tempfile::dir::TempDir, std::io::error::Error> as tempfile::error::IoResultExt<tempfile::dir::TempDir>>::with_err_path::<tempfile::util::create_helper<tempfile::dir::TempDir, <tempfile::Builder>::tempdir_in<std::path::PathBuf>::{closure#0}>::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<tempfile::file::NamedTempFile, std::io::error::Error> as tempfile::error::IoResultExt<tempfile::file::NamedTempFile>>::with_err_path::<tempfile::util::create_helper<tempfile::file::NamedTempFile, <tempfile::Builder>::tempfile_in<std::path::PathBuf>::{closure#0}>::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<std::fs::File, std::io::error::Error> as tempfile::error::IoResultExt<std::fs::File>>::with_err_path::<tempfile::util::create_helper<std::fs::File, tempfile::file::imp::unix::create_unix::{closure#0}>::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<std::fs::File, std::io::error::Error> as tempfile::error::IoResultExt<std::fs::File>>::with_err_path::<<tempfile::file::NamedTempFile>::reopen::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<std::fs::File, std::io::error::Error> as tempfile::error::IoResultExt<std::fs::File>>::with_err_path::<tempfile::file::create_named::{closure#0}, std::path::PathBuf>
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_to_end::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_vectored::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_to_string::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write_vectored::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<tempfile::dir::TempDir>::close::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<tempfile::file::TempPath>::close::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<tempfile::dir::imp::unix::create::{closure#0}, &std::path::PathBuf>
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_exact::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write_all::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write_fmt::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<u64, std::io::error::Error> as tempfile::error::IoResultExt<u64>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Seek>::seek::{closure#0}, &std::path::Path>
45
}