use std::fmt;
use std::io;
#[derive(Debug)]
pub enum LufsError {
Io(io::Error),
UnsupportedFormat(String),
DecodeError(String),
EbuR128Error(String),
InvalidData(String),
}
impl fmt::Display for LufsError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
LufsError::Io(e) => write!(f, "IO error: {}", e),
LufsError::UnsupportedFormat(format) => write!(f, "Unsupported format: {}", format),
LufsError::DecodeError(msg) => write!(f, "Decode error: {}", msg),
LufsError::EbuR128Error(msg) => write!(f, "EBU R128 error: {}", msg),
LufsError::InvalidData(msg) => write!(f, "Invalid data: {}", msg),
}
}
}
impl std::error::Error for LufsError {}
impl From<io::Error> for LufsError {
fn from(err: io::Error) -> Self {
LufsError::Io(err)
}
}
pub type Result<T> = std::result::Result<T, LufsError>;