creek_encode_wav/
error.rs1use std::io;
2
3use crate::Format;
4
5#[derive(Debug)]
6pub enum WavOpenError {
7 Io(io::Error),
8 CodecNotImplementedYet { num_channels: u16, format: Format },
9}
10
11impl std::error::Error for WavOpenError {}
12
13impl std::fmt::Display for WavOpenError {
14 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15 match self {
16 WavOpenError::Io(e) => write!(f, "IO error: {:?}", e),
17 WavOpenError::CodecNotImplementedYet {
18 num_channels,
19 format,
20 } => {
21 write!(
22 f,
23 "Codec not implemented yet: num_channels: {}, format: {:?}",
24 num_channels, format
25 )
26 }
27 }
28 }
29}
30
31impl From<io::Error> for WavOpenError {
32 fn from(e: io::Error) -> Self {
33 WavOpenError::Io(e)
34 }
35}
36
37#[derive(Debug)]
38pub enum WavFatalError {
39 Io(io::Error),
40 ReachedMaxSize,
41 CouldNotGetFileName,
42}
43
44impl std::error::Error for WavFatalError {}
45
46impl std::fmt::Display for WavFatalError {
47 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
48 match self {
49 WavFatalError::Io(e) => write!(f, "IO error: {:?}", e),
50 WavFatalError::ReachedMaxSize => write!(f, "Reached maximum WAVE file size of 4GB"),
51 WavFatalError::CouldNotGetFileName => {
52 write!(f, "There was an error reading the name of the file")
53 }
54 }
55 }
56}
57
58impl From<io::Error> for WavFatalError {
59 fn from(e: io::Error) -> Self {
60 WavFatalError::Io(e)
61 }
62}