file_storage/error/
reason.rs

1use std::fmt::{Display, Formatter};
2
3/// The reason for a file or folder operation error.
4#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
5pub enum Reason {
6    /// The file system could not be resolved.
7    UnknownFileSystem,
8
9    /// The file system does not support the operation.
10    UnsupportedOperation,
11
12    /// The file was not found.
13    FileNotFound,
14
15    /// The file already exists.
16    FileAlreadyExists,
17
18    /// Another uncategorized reason.
19    Other,
20}
21
22impl Display for Reason {
23    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
24        let s: &str = match self {
25            Reason::UnknownFileSystem => "unknown file system",
26            Reason::UnsupportedOperation => "unsupported operation",
27            Reason::FileNotFound => "file not found",
28            Reason::FileAlreadyExists => "file already exists",
29            Reason::Other => "other",
30        };
31        write!(f, "{}", s)
32    }
33}