use std::fmt;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Error {
Corrupt,
TooLarge,
Unsupported,
CrcMismatch,
BufferTooSmall,
InvalidInput(String),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Corrupt => write!(f, "s2: corrupt input"),
Error::TooLarge => write!(f, "s2: decoded block is too large"),
Error::Unsupported => write!(f, "s2: unsupported input"),
Error::CrcMismatch => write!(f, "s2: corrupt input, crc mismatch"),
Error::BufferTooSmall => write!(f, "s2: buffer too small"),
Error::InvalidInput(msg) => write!(f, "s2: invalid input: {}", msg),
}
}
}
impl std::error::Error for Error {}