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