use std::fmt;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub enum Error {
Io(std::io::Error),
LargeFileSize,
InvalidWavFile(String),
}
impl From<std::io::Error> for Error {
fn from(err: std::io::Error) -> Self {
Error::Io(err)
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Io(err) => write!(f, "IO error: {}", err),
Error::LargeFileSize => write!(f, "File size is too large, maximum file size is 4 GB"),
Error::InvalidWavFile(msg) => write!(f, "Invalid wav file, {}", msg),
}
}
}