use std::fmt;
#[derive(Debug)]
pub enum SdmpError {
NotAnSdmpFile,
UnknownCodec(u8),
UnexpectedEof,
InvalidUtf8,
IoError(std::io::Error),
CorruptManifest,
}
impl fmt::Display for SdmpError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::NotAnSdmpFile => write!(f, "not a valid .srcdmp file"),
Self::UnknownCodec(byte) => write!(f, "unknown codec: 0x{byte:02X}"),
Self::UnexpectedEof => write!(f, "unexpected end of file"),
Self::InvalidUtf8 => write!(f, "decoded bytes are not valid UTF-8"),
Self::IoError(e) => write!(f, "io error: {e}"),
Self::CorruptManifest => write!(f, "manifest is corrupt or malformed"),
}
}
}
impl From<std::io::Error> for SdmpError {
fn from(e: std::io::Error) -> Self {
Self::IoError(e)
}
}