1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use core::fmt::{Display, Formatter, Result};
use crate::types::ClusterID;
pub enum Error<E> {
Generic(&'static str),
IO(E),
NotExFAT,
Checksum,
EOF,
NoSpace,
BadCluster(ClusterID),
TexFATNotSupported,
UpcaseTableMissing,
UpcaseTableChecksum,
AllocationBitmapMissing,
NoSuchFileOrDirectory,
AlreadyOpen,
}
impl<E: Display> Display for Error<E> {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
match self {
Self::Generic(s) => write!(f, "Generic error({})", s),
Self::IO(e) => write!(f, "IO({})", e),
Self::NotExFAT => write!(f, "Not ExFAT filesystem"),
Self::TexFATNotSupported => write!(f, "TexFAT not supported"),
Self::Checksum => write!(f, "Checksum mismatch"),
Self::EOF => write!(f, "End of file"),
Self::NoSpace => write!(f, "Insufficent space"),
Self::BadCluster(id) => write!(f, "Bad cluster({:#X})", u32::from(*id)),
Self::UpcaseTableMissing => write!(f, "Upcase table missing"),
Self::UpcaseTableChecksum => write!(f, "Upcase table checksum mismatch"),
Self::AllocationBitmapMissing => write!(f, "Allocation bitmap missing"),
Self::NoSuchFileOrDirectory => write!(f, "No such file or directory"),
Self::AlreadyOpen => write!(f, "File or directory already open"),
}
}
}