stak_file/file_system/
error.rs

1use core::{
2    error,
3    fmt::{self, Display, Formatter},
4};
5
6/// An error.
7#[derive(Clone, Copy, Debug, Eq, PartialEq)]
8pub enum FileError {
9    /// An open failure.
10    Open,
11    /// A close failure.
12    Close,
13    /// An invalid file descriptor.
14    InvalidFileDescriptor,
15    /// A read failure.
16    Read,
17    /// A write failure.
18    Write,
19    /// A flush failure.
20    Flush,
21    /// A deletion failure.
22    Delete,
23    /// A existence check failure.
24    Exists,
25    /// A path decode failure.
26    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}