file_storage/error/
reason.rs1use std::fmt::{Display, Formatter};
2
3#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
5pub enum Reason {
6 UnknownFileSystem,
8
9 UnsupportedOperation,
11
12 FileNotFound,
14
15 FileAlreadyExists,
17
18 FileContentNotUTF8,
20
21 InvalidPath,
23
24 Other,
26}
27
28impl Display for Reason {
29 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
30 let s: &str = match self {
31 Reason::UnknownFileSystem => "unknown file system",
32 Reason::UnsupportedOperation => "unsupported operation",
33 Reason::FileNotFound => "file not found",
34 Reason::FileAlreadyExists => "file already exists",
35 Reason::FileContentNotUTF8 => "file content not utf-8",
36 Reason::InvalidPath => "invalid path",
37 Reason::Other => "other",
38 };
39 f.write_str(s)
40 }
41}