use crate::sfa::checksum::Checksum;
#[derive(Debug)]
pub enum Error {
Io(std::io::Error),
InvalidHeader,
InvalidVersion,
UnsupportedChecksumType,
ChecksumMismatch {
got: Checksum,
expected: Checksum,
},
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "SfaError: {self:?}")
}
}
impl From<std::io::Error> for Error {
fn from(inner: std::io::Error) -> Self {
Self::Io(inner)
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::Io(inner) => Some(inner),
_ => None,
}
}
}