stak_file/file_system/
error.rsuse core::{
error,
fmt::{self, Display, Formatter},
};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum FileError {
Open,
Close,
Read,
Write,
Delete,
Exists,
}
impl error::Error for FileError {}
impl Display for FileError {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
match self {
Self::Open => write!(formatter, "cannot open file"),
Self::Close => write!(formatter, "cannot close file"),
Self::Read => write!(formatter, "cannot read file"),
Self::Write => write!(formatter, "cannot write file"),
Self::Delete => write!(formatter, "cannot delete file"),
Self::Exists => write!(formatter, "cannot check file existence"),
}
}
}