Skip to content

Commit 91acb9e

Browse files
authored
chore(common): drop unused fs import and fix doc links (#12535)
Update fs.rs
1 parent 10cd61a commit 91acb9e

File tree

1 file changed

+20
-23
lines changed
  • crates/common/src/errors

1 file changed

+20
-23
lines changed

crates/common/src/errors/fs.rs

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,36 @@ use std::{
33
path::{Path, PathBuf},
44
};
55

6-
#[expect(unused_imports)]
7-
use std::fs::{self, File};
8-
96
/// Various error variants for `fs` operations that serve as an addition to the io::Error which
107
/// does not provide any information about the path.
118
#[derive(Debug, thiserror::Error)]
129
#[expect(missing_docs)]
1310
pub enum FsPathError {
14-
/// Provides additional path context for [`fs::write`].
11+
/// Provides additional path context for [`std::fs::write`].
1512
#[error("failed to write to {path:?}: {source}")]
1613
Write { source: io::Error, path: PathBuf },
17-
/// Provides additional path context for [`fs::read`].
14+
/// Provides additional path context for [`std::fs::read`].
1815
#[error("failed to read from {path:?}: {source}")]
1916
Read { source: io::Error, path: PathBuf },
20-
/// Provides additional path context for [`fs::copy`].
17+
/// Provides additional path context for [`std::fs::copy`].
2118
#[error("failed to copy from {from:?} to {to:?}: {source}")]
2219
Copy { source: io::Error, from: PathBuf, to: PathBuf },
23-
/// Provides additional path context for [`fs::read_link`].
20+
/// Provides additional path context for [`std::fs::read_link`].
2421
#[error("failed to read from {path:?}: {source}")]
2522
ReadLink { source: io::Error, path: PathBuf },
26-
/// Provides additional path context for [`File::create`].
23+
/// Provides additional path context for [`std::fs::File::create`].
2724
#[error("failed to create file {path:?}: {source}")]
2825
CreateFile { source: io::Error, path: PathBuf },
29-
/// Provides additional path context for [`fs::remove_file`].
26+
/// Provides additional path context for [`std::fs::remove_file`].
3027
#[error("failed to remove file {path:?}: {source}")]
3128
RemoveFile { source: io::Error, path: PathBuf },
32-
/// Provides additional path context for [`fs::create_dir`].
29+
/// Provides additional path context for [`std::fs::create_dir`].
3330
#[error("failed to create dir {path:?}: {source}")]
3431
CreateDir { source: io::Error, path: PathBuf },
35-
/// Provides additional path context for [`fs::remove_dir`].
32+
/// Provides additional path context for [`std::fs::remove_dir`].
3633
#[error("failed to remove dir {path:?}: {source}")]
3734
RemoveDir { source: io::Error, path: PathBuf },
38-
/// Provides additional path context for [`File::open`].
35+
/// Provides additional path context for [`std::fs::File::open`].
3936
#[error("failed to open file {path:?}: {source}")]
4037
Open { source: io::Error, path: PathBuf },
4138
#[error("failed to lock file {path:?}: {source}")]
@@ -51,57 +48,57 @@ pub enum FsPathError {
5148
}
5249

5350
impl FsPathError {
54-
/// Returns the complementary error variant for [`fs::write`].
51+
/// Returns the complementary error variant for [`std::fs::write`].
5552
pub fn write(source: io::Error, path: impl Into<PathBuf>) -> Self {
5653
Self::Write { source, path: path.into() }
5754
}
5855

59-
/// Returns the complementary error variant for [`fs::read`].
56+
/// Returns the complementary error variant for [`std::fs::read`].
6057
pub fn read(source: io::Error, path: impl Into<PathBuf>) -> Self {
6158
Self::Read { source, path: path.into() }
6259
}
6360

64-
/// Returns the complementary error variant for [`fs::copy`].
61+
/// Returns the complementary error variant for [`std::fs::copy`].
6562
pub fn copy(source: io::Error, from: impl Into<PathBuf>, to: impl Into<PathBuf>) -> Self {
6663
Self::Copy { source, from: from.into(), to: to.into() }
6764
}
6865

69-
/// Returns the complementary error variant for [`fs::read_link`].
66+
/// Returns the complementary error variant for [`std::fs::read_link`].
7067
pub fn read_link(source: io::Error, path: impl Into<PathBuf>) -> Self {
7168
Self::ReadLink { source, path: path.into() }
7269
}
7370

74-
/// Returns the complementary error variant for [`File::create`].
71+
/// Returns the complementary error variant for [`std::fs::File::create`].
7572
pub fn create_file(source: io::Error, path: impl Into<PathBuf>) -> Self {
7673
Self::CreateFile { source, path: path.into() }
7774
}
7875

79-
/// Returns the complementary error variant for [`fs::remove_file`].
76+
/// Returns the complementary error variant for [`std::fs::remove_file`].
8077
pub fn remove_file(source: io::Error, path: impl Into<PathBuf>) -> Self {
8178
Self::RemoveFile { source, path: path.into() }
8279
}
8380

84-
/// Returns the complementary error variant for [`fs::create_dir`].
81+
/// Returns the complementary error variant for [`std::fs::create_dir`].
8582
pub fn create_dir(source: io::Error, path: impl Into<PathBuf>) -> Self {
8683
Self::CreateDir { source, path: path.into() }
8784
}
8885

89-
/// Returns the complementary error variant for [`fs::remove_dir`].
86+
/// Returns the complementary error variant for [`std::fs::remove_dir`].
9087
pub fn remove_dir(source: io::Error, path: impl Into<PathBuf>) -> Self {
9188
Self::RemoveDir { source, path: path.into() }
9289
}
9390

94-
/// Returns the complementary error variant for [`File::open`].
91+
/// Returns the complementary error variant for [`std::fs::File::open`].
9592
pub fn open(source: io::Error, path: impl Into<PathBuf>) -> Self {
9693
Self::Open { source, path: path.into() }
9794
}
9895

99-
/// Returns the complementary error variant for [`File::lock`].
96+
/// Returns the complementary error variant when locking a file.
10097
pub fn lock(source: io::Error, path: impl Into<PathBuf>) -> Self {
10198
Self::Lock { source, path: path.into() }
10299
}
103100

104-
/// Returns the complementary error variant for [`File::unlock`].
101+
/// Returns the complementary error variant when unlocking a file.
105102
pub fn unlock(source: io::Error, path: impl Into<PathBuf>) -> Self {
106103
Self::Unlock { source, path: path.into() }
107104
}

0 commit comments

Comments
 (0)