pub enum Error {
Show 25 variants
InvalidBootSignature {
found: u16,
},
UnsupportedFatType(&'static str),
InvalidFsInfoSignature {
field: &'static str,
expected: u32,
found: u32,
},
InvalidShortFilename,
ClusterOutOfBounds {
cluster: u32,
max: u32,
},
BadCluster {
cluster: u32,
},
UnexpectedEndOfChain {
cluster: u32,
},
Io(Error),
IoContext {
op: &'static str,
sector: Option<u64>,
source: Error,
},
CorruptFilesystem {
context: &'static str,
},
ClusterLoop {
cluster: u32,
},
NotAFile,
NotADirectory,
EntryNotFound,
InvalidPath,
NoFreeSpace,
DirectoryFull,
InvalidFilename,
AlreadyExists,
DirectoryNotEmpty,
InvalidAttributeChange {
bit: &'static str,
},
CacheDirtyEviction {
sector: u32,
},
VolumeTooSmall {
size: u64,
min_size: u64,
},
VolumeTooLarge {
size: u64,
max_size: u64,
},
InvalidFormatOption {
option: &'static str,
reason: &'static str,
},
}Expand description
Errors that can occur when working with FAT file systems.
Variants§
InvalidBootSignature
Invalid boot signature (expected 0xAA55)
UnsupportedFatType(&'static str)
Unsupported FAT type (FAT12/16 when FAT32 expected, or vice versa)
InvalidFsInfoSignature
Invalid FSInfo signature
Fields
InvalidShortFilename
Invalid short filename (contains disallowed characters)
ClusterOutOfBounds
Cluster number out of bounds
BadCluster
Bad cluster marker encountered
UnexpectedEndOfChain
End of cluster chain reached unexpectedly
Io(Error)
I/O error from the underlying storage
IoContext
I/O error annotated with the operation and (optionally) the sector
where it happened. Used at trust boundaries — boot sector parse,
FSInfo read, FAT chain walk entry, directory iteration head — so
callers can tell which on-disk structure tripped the failure
rather than just seeing an opaque Self::Io.
Fields
CorruptFilesystem
On-disk arithmetic on an untrusted value would overflow or underflow.
The context string identifies which on-disk value triggered the
failure (e.g. "sectors_per_fat * sector_size" when a corrupt BPB
would push the FAT region past usize::MAX). This is distinct from
ClusterOutOfBounds, which catches valid arithmetic that lands
outside the cluster range.
ClusterLoop
A FAT chain walk visited more clusters than the filesystem contains,
which means the chain has a loop. Always corruption — a healthy chain
is bounded by max_cluster - 1 (clusters 0 and 1 are reserved).
NotAFile
File is not a regular file (e.g., is a directory)
NotADirectory
Entry is not a directory
EntryNotFound
Entry not found in directory
InvalidPath
Path is invalid (empty, malformed)
NoFreeSpace
No free clusters available
DirectoryFull
Directory is full (no free entry slots)
InvalidFilename
Filename is invalid or too long
AlreadyExists
Entry with this name already exists
DirectoryNotEmpty
Cannot delete non-empty directory
InvalidAttributeChange
Attempted to flip an immutable attribute bit (DIRECTORY or
VOLUME_ID) on an existing entry. Those bits identify the kind of
entry on disk; changing them in-place would leave the cluster chain
or root volume label inconsistent.
CacheDirtyEviction
A read-only crate::cache::FatSectorCache operation needed to evict
a sector to make room for a new one, but every cached sector is
dirty. The caller must call crate::cache::FatSectorCache::flush
(or crate::FatVolume::flush) before continuing — read paths can’t
safely drop unwritten dirty data.
VolumeTooSmall
Volume is too small for the requested format
VolumeTooLarge
Volume is too large for the requested FAT type
InvalidFormatOption
Invalid format option
Trait Implementations§
Source§impl Error for Error
Available on crate feature std only.
impl Error for Error
std only.1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()