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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
use core::fmt;
/// Partition manipulation error
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PartitionError {
/// Magic bytes is not a valid
InvalidMagic,
/// Partition type is not a valid
InvalidType(u8),
/// Partition subtype is not a valid
InvalidSubType(u8),
/// User-defined type is not a valid
InvalidUserType(u8),
/// OTA partition number is not a valid
InvalidOtaNumber(u8),
/// String data is not a valid
InvalidString,
/// Partition alignment is not a valid
InvalidAlignment,
/// MD5 checksum is not a valid
InvalidMd5,
/// Not enough data
NotEnoughData,
/// Too many data
TooManyData,
}
impl fmt::Display for PartitionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use PartitionError::*;
match self {
InvalidMagic => "Invalid magic".fmt(f),
InvalidType(ty) => {
"Invalid type: ".fmt(f)?;
ty.fmt(f)
}
InvalidSubType(ty) => {
"Invalid sub type: ".fmt(f)?;
ty.fmt(f)
}
InvalidUserType(ty) => {
"Invalid user type: ".fmt(f)?;
ty.fmt(f)
}
InvalidOtaNumber(no) => {
"Invalid OTA: #".fmt(f)?;
no.fmt(f)
}
InvalidString => "Invalid string".fmt(f),
InvalidAlignment => "Invalid alignment".fmt(f),
InvalidMd5 => "Invalid MD5".fmt(f),
NotEnoughData => "Not enough data".fmt(f),
TooManyData => "Too many data".fmt(f),
}
}
}