stak_file/file_system/
error.rs1use core::{
2 error,
3 fmt::{self, Display, Formatter},
4};
5
6#[derive(Clone, Copy, Debug, Eq, PartialEq)]
8pub enum FileError {
9 Open,
11 Close,
13 InvalidFileDescriptor,
15 Read,
17 Write,
19 Flush,
21 Delete,
23 Exists,
25 PathDecode,
27}
28
29impl error::Error for FileError {}
30
31impl Display for FileError {
32 fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
33 match self {
34 Self::Open => write!(formatter, "cannot open file"),
35 Self::Close => write!(formatter, "cannot close file"),
36 Self::InvalidFileDescriptor => write!(formatter, "invalid file descriptor"),
37 Self::Read => write!(formatter, "cannot read file"),
38 Self::Write => write!(formatter, "cannot write file"),
39 Self::Flush => write!(formatter, "cannot flush file"),
40 Self::Delete => write!(formatter, "cannot delete file"),
41 Self::Exists => write!(formatter, "cannot check file existence"),
42 Self::PathDecode => write!(formatter, "cannot decode path"),
43 }
44 }
45}