#[non_exhaustive]pub enum BootError {
NotFat,
UnsupportedFormat(Format),
BadGeometry(Geometry),
ShortBlock {
len: usize,
},
}Expand description
What can go wrong reading a boot sector.
Separate from Error for the same reason as FatError, and it
is the same reason: none of it involves a device.
BootSector::parse is handed a block that has
already been read, so it either understands those 512 bytes or it does
not — there is no transfer left to fail.
Being its own type is what lets parse say so. Reported through
Error it would have had to be generic over a device error it
could never produce, and a caller parsing a block it had read itself
would have needed a turbofish naming a type that never appeared —
BootSector::parse::<()>(&block).
Converts into Error with ?, so mounting, which does touch a
device, needs neither turbofish nor map_err.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
NotFat
No boot signature — this is not a FAT volume, or not the right sector.
The usual cause is a partitioned card: the partition table sits where the boot sector was looked for, so the volume has to be mounted at the partition’s first block rather than at block 0.
UnsupportedFormat(Format)
A FAT12 or FAT16 volume, recognised and declined.
BadGeometry(Geometry)
A boot sector field this crate will not accept.
ShortBlock
The block handed in was shorter than a sector.
A caller’s mistake rather than anything about a volume: every field a boot sector holds lives in its first 512 bytes, so a shorter slice has nothing to parse.
Reported rather than asserted, for the reason given on
Error::BufferLength — indexing past the end would panic, and a
bare-metal target has no unwinder to catch it. The two are the same
kind of mistake and get the same treatment.
Trait Implementations§
impl Copy for BootError
impl Eq for BootError
Source§impl Error for BootError
impl Error for BootError
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()