pub type Result<T> = std::result::Result<T, Error>;
pub enum Error {
RiffChunkHeaderIsNotFound,
WaveChunkHeaderIsNotFound,
FmtChunkIsNotFound,
DataIsNotEnough,
}
impl std::error::Error for Error {}
impl std::fmt::Debug for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
<Self as std::fmt::Display>::fmt(self, f)
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
use Error::*;
match self {
RiffChunkHeaderIsNotFound => "`RIFF` label is not found.".fmt(f),
WaveChunkHeaderIsNotFound => "`WAVE` label is not found.".fmt(f),
FmtChunkIsNotFound => "`fmt ` label is not found.".fmt(f),
DataIsNotEnough => "data is not enough".fmt(f),
}
}
}