1use core::fmt;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum AffsError {
8 BlockReadError,
10 InvalidDosType,
12 InvalidBlockType,
14 InvalidSecType,
16 ChecksumMismatch,
18 BlockOutOfRange,
20 EntryNotFound,
22 NameTooLong,
24 InvalidState,
26 EndOfFile,
28 NotAFile,
30 NotADirectory,
32 BufferTooSmall,
34 InvalidDataSequence,
36}
37
38impl fmt::Display for AffsError {
39 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40 match self {
41 Self::BlockReadError => write!(f, "block read error"),
42 Self::InvalidDosType => write!(f, "invalid DOS type signature"),
43 Self::InvalidBlockType => write!(f, "invalid block type"),
44 Self::InvalidSecType => write!(f, "invalid secondary type"),
45 Self::ChecksumMismatch => write!(f, "checksum mismatch"),
46 Self::BlockOutOfRange => write!(f, "block out of range"),
47 Self::EntryNotFound => write!(f, "entry not found"),
48 Self::NameTooLong => write!(f, "name too long"),
49 Self::InvalidState => write!(f, "invalid filesystem state"),
50 Self::EndOfFile => write!(f, "end of file"),
51 Self::NotAFile => write!(f, "not a file"),
52 Self::NotADirectory => write!(f, "not a directory"),
53 Self::BufferTooSmall => write!(f, "buffer too small"),
54 Self::InvalidDataSequence => write!(f, "invalid data block sequence"),
55 }
56 }
57}
58
59#[cfg(feature = "std")]
60impl std::error::Error for AffsError {}
61
62pub type Result<T> = core::result::Result<T, AffsError>;