1use std::fmt;
2
3pub type Result<T> = std::result::Result<T, Error>;
5
6#[derive(Debug)]
8pub enum Error {
9 Io(std::io::Error),
11 LargeFileSize,
13 InvalidWavFile(String),
15}
16impl From<std::io::Error> for Error {
17 fn from(err: std::io::Error) -> Self {
18 Error::Io(err)
19 }
20}
21
22impl fmt::Display for Error {
23 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24 match self {
25 Error::Io(err) => write!(f, "IO error: {}", err),
26 Error::LargeFileSize => write!(f, "File size is too large, maximum file size is 4 GB"),
27 Error::InvalidWavFile(msg) => write!(f, "Invalid wav file, {}", msg),
28 }
29 }
30}