1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::io;

// We derive `Debug` because all types should probably derive `Debug`.
#[derive(Debug)]
pub enum SonogramError {
    Io(io::Error),
    #[cfg(feature = "hound")]
    Hound(hound::Error),

    // Our own errors
    InvalidCodec,
    InvalidChannel,
    InvalidDivisor,
    IncompleteData,
}

impl From<io::Error> for SonogramError {
    fn from(err: io::Error) -> SonogramError {
        SonogramError::Io(err)
    }
}

#[cfg(feature = "hound")]
impl From<hound::Error> for SonogramError {
    fn from(err: hound::Error) -> SonogramError {
        SonogramError::Hound(err)
    }
}