use core::fmt;
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum Error {
Config(&'static str),
BackwardsTime,
QueueFull,
IrqQueueFull,
CaptureOverflow,
Format(&'static str),
TooLarge,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Config(reason) | Self::Format(reason) => f.write_str(reason),
Self::BackwardsTime => f.write_str("machine time cannot move backwards"),
Self::QueueFull => {
f.write_str("sound command queue is full; render audio before retrying")
}
Self::IrqQueueFull => {
f.write_str("DMA completion queue is full; poll completion events before retrying")
}
Self::CaptureOverflow => f.write_str(
"synthesis capture overflowed; drain it more often or increase capacity",
),
Self::TooLarge => f.write_str("time or file size exceeds the supported range"),
}
}
}
impl std::error::Error for Error {}
pub type Result<T> = core::result::Result<T, Error>;