parallel_disk_usage/reporter/error_report/
operation.rs

1/// Operation that caused the error
2#[derive(Debug, Clone, Copy, PartialEq, Eq)]
3pub enum Operation {
4    /// Error is caused by calling [`std::fs::symlink_metadata`].
5    SymlinkMetadata,
6    /// Error is caused by calling [`std::fs::read_dir`].
7    ReadDirectory,
8    /// Error when trying to access [`std::fs::DirEntry`] of one of the element of [`std::fs::read_dir`].
9    AccessEntry,
10}
11
12impl Operation {
13    /// Get name of the operation.
14    pub const fn name(self) -> &'static str {
15        use Operation::*;
16        match self {
17            SymlinkMetadata => "symlink_metadata",
18            ReadDirectory => "read_dir",
19            AccessEntry => "access entry",
20        }
21    }
22}
23
24#[cfg(test)]
25mod test_operation {
26    use super::*;
27
28    macro_rules! name_display {
29        ($name:ident, $variant:ident, $text:literal) => {
30            #[test]
31            fn $name() {
32                assert_eq!(Operation::$variant.name(), $text);
33            }
34        };
35    }
36
37    name_display!(symlink_metadata, SymlinkMetadata, "symlink_metadata");
38    name_display!(read_directory, ReadDirectory, "read_dir");
39    name_display!(access_entry, AccessEntry, "access entry");
40}