-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathoperation.rs
More file actions
36 lines (32 loc) · 946 Bytes
/
operation.rs
File metadata and controls
36 lines (32 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/// Operation that caused the error
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Operation {
/// Error is caused by calling [`std::fs::symlink_metadata`].
SymlinkMetadata,
/// Error is caused by calling [`std::fs::read_dir`].
ReadDirectory,
}
impl Operation {
/// Get name of the operation.
pub const fn name(self) -> &'static str {
use Operation::*;
match self {
SymlinkMetadata => "symlink_metadata",
ReadDirectory => "read_dir",
}
}
}
#[cfg(test)]
mod test_operation {
use super::*;
macro_rules! name_display {
($name:ident, $variant:ident, $text:literal) => {
#[test]
fn $name() {
assert_eq!(Operation::$variant.name(), $text);
}
};
}
name_display!(symlink_metadata, SymlinkMetadata, "symlink_metadata");
name_display!(read_directory, ReadDirectory, "read_dir");
}