1use core::fmt;
2
3#[derive(Debug, Clone)]
4pub enum AecError {
5 InvalidInput(&'static str),
6 Unsupported(&'static str),
7 NotImplemented(&'static str),
8 UnexpectedEof { bit_pos: usize },
9 UnexpectedEofDuringDecode { bit_pos: usize, samples_written: usize },
10}
11
12impl fmt::Display for AecError {
13 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14 match self {
15 AecError::InvalidInput(s) => write!(f, "invalid input: {s}"),
16 AecError::Unsupported(s) => write!(f, "unsupported: {s}"),
17 AecError::NotImplemented(s) => write!(f, "not implemented: {s}"),
18 AecError::UnexpectedEof { bit_pos } => write!(f, "unexpected end of input at bit {bit_pos}"),
19 AecError::UnexpectedEofDuringDecode { bit_pos, samples_written } => {
20 write!(f, "unexpected end of input at bit {bit_pos} (wrote {samples_written} samples)")
21 }
22 }
23 }
24}
25
26impl std::error::Error for AecError {}