1use std::fmt::Debug;
5use std::path::Path;
6use std::path::PathBuf;
7
8use miette::IntoDiagnostic;
9use tracing::instrument;
10
11#[instrument(level = "trace")]
12pub fn rename<P, Q>(from: P, to: Q) -> miette::Result<()>
13where
14 P: AsRef<Path> + Debug,
15 Q: AsRef<Path> + Debug,
16{
17 #[expect(clippy::disallowed_methods)]
18 fs_err::rename(from, to).into_diagnostic()
19}
20
21#[instrument(level = "trace")]
22pub fn create_dir<P>(path: P) -> miette::Result<()>
23where
24 P: AsRef<Path> + Debug,
25{
26 #[expect(clippy::disallowed_methods)]
27 fs_err::create_dir(path).into_diagnostic()
28}
29
30#[instrument(level = "trace")]
31pub fn create_dir_all<P>(path: P) -> miette::Result<()>
32where
33 P: AsRef<Path> + Debug,
34{
35 #[expect(clippy::disallowed_methods)]
36 fs_err::create_dir_all(path).into_diagnostic()
37}
38
39#[instrument(level = "trace")]
40pub fn remove_dir<P>(path: P) -> miette::Result<()>
41where
42 P: AsRef<Path> + Debug,
43{
44 #[expect(clippy::disallowed_methods)]
45 fs_err::remove_dir(path).into_diagnostic()
46}
47
48#[instrument(level = "trace")]
49pub fn read_to_string<P>(path: P) -> miette::Result<String>
50where
51 P: AsRef<Path> + Debug,
52{
53 #[expect(clippy::disallowed_methods)]
54 fs_err::read_to_string(path).into_diagnostic()
55}
56
57#[instrument(level = "trace")]
58pub fn copy<P, Q>(from: P, to: Q) -> miette::Result<u64>
59where
60 P: AsRef<Path> + Debug,
61 Q: AsRef<Path> + Debug,
62{
63 #[expect(clippy::disallowed_methods)]
64 fs_err::copy(from, to).into_diagnostic()
65}
66
67#[instrument(level = "trace")]
68pub fn write<P, C>(path: P, contents: C) -> miette::Result<()>
69where
70 P: AsRef<Path> + Debug,
71 C: AsRef<[u8]> + Debug,
72{
73 #[expect(clippy::disallowed_methods)]
74 fs_err::write(path, contents).into_diagnostic()
75}
76
77#[instrument(level = "trace")]
78pub fn read_dir<P>(path: P) -> miette::Result<fs_err::ReadDir>
79where
80 P: Into<PathBuf> + Debug,
81{
82 #[expect(clippy::disallowed_methods)]
83 fs_err::read_dir(path).into_diagnostic()
84}