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 NotASymlink,
38 SymlinkTooLong,
40}
41
42impl fmt::Display for AffsError {
43 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44 match self {
45 Self::BlockReadError => write!(f, "block read error"),
46 Self::InvalidDosType => write!(f, "invalid DOS type signature"),
47 Self::InvalidBlockType => write!(f, "invalid block type"),
48 Self::InvalidSecType => write!(f, "invalid secondary type"),
49 Self::ChecksumMismatch => write!(f, "checksum mismatch"),
50 Self::BlockOutOfRange => write!(f, "block out of range"),
51 Self::EntryNotFound => write!(f, "entry not found"),
52 Self::NameTooLong => write!(f, "name too long"),
53 Self::InvalidState => write!(f, "invalid filesystem state"),
54 Self::EndOfFile => write!(f, "end of file"),
55 Self::NotAFile => write!(f, "not a file"),
56 Self::NotADirectory => write!(f, "not a directory"),
57 Self::BufferTooSmall => write!(f, "buffer too small"),
58 Self::InvalidDataSequence => write!(f, "invalid data block sequence"),
59 Self::NotASymlink => write!(f, "not a symlink"),
60 Self::SymlinkTooLong => write!(f, "symlink target too long"),
61 }
62 }
63}
64
65#[cfg(feature = "std")]
66impl std::error::Error for AffsError {}
67
68pub type Result<T> = core::result::Result<T, AffsError>;