#[derive(Copy, Clone, Debug)]
pub enum InstantiateError {
UnknownError,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum EventError {
DataTooLarge {
max_supported_size: usize,
actual_size: usize,
},
SequenceFull { capacity: usize, requested: usize },
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum RunError {
SampleCountTooSmall { min_supported: usize, actual: usize },
SampleCountTooLarge { max_supported: usize, actual: usize },
AudioInputsSizeMismatch { expected: usize, actual: usize },
AudioInputSampleCountTooSmall { expected: usize, actual: usize },
AudioOutputsSizeMismatch { expected: usize, actual: usize },
AudioOutputSampleCountTooSmall { expected: usize, actual: usize },
AtomSequenceInputsSizeMismatch { expected: usize, actual: usize },
AtomSequenceOutputsSizeMismatch { expected: usize, actual: usize },
CVInputsSizeMismatch { expected: usize, actual: usize },
CVOutputsSizeMismatch { expected: usize, actual: usize },
}
impl std::error::Error for InstantiateError {}
impl std::error::Error for EventError {}
impl std::error::Error for RunError {}
impl std::fmt::Display for InstantiateError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
InstantiateError::UnknownError => f.write_str("unknown error"),
}
}
}
impl std::fmt::Display for EventError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
EventError::DataTooLarge {
max_supported_size,
actual_size,
} => write!(
f,
"data of size {actual_size} is larger than maximum supported size of {max_supported_size}",
),
EventError::SequenceFull {
capacity,
requested,
} => write!(
f,
"sequence with capacity {capacity} is full but requested {requested}",
),
}
}
}
impl std::fmt::Display for RunError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
RunError::SampleCountTooSmall {
min_supported,
actual,
} => write!(
f,
"sample count of {actual} is less than minimum supported sample count of {min_supported}",
),
RunError::SampleCountTooLarge {
max_supported,
actual,
} => write!(
f,
"sample count of {actual} is more than maximum supported sample count of {max_supported}",
),
RunError::AudioInputsSizeMismatch { expected, actual } => {
write!(f, "expected {expected} audio inputs but found {actual}")
}
RunError::AudioInputSampleCountTooSmall { expected, actual } => write!(
f,
"audio input required at least {expected} samples but has {actual}",
),
RunError::AudioOutputsSizeMismatch { expected, actual } => write!(
f,
"expected {expected} audio outputs but found {actual}",
),
RunError::AudioOutputSampleCountTooSmall { expected, actual } => write!(
f,
"audio output required at least {expected} samples but has {actual}",
),
RunError::AtomSequenceInputsSizeMismatch { expected, actual } => write!(
f,
"expected {expected} atom sequence inputs but found {actual}",
),
RunError::AtomSequenceOutputsSizeMismatch { expected, actual } => write!(
f,
"expected {expected} atom sequence outputs but found {actual}",
),
RunError::CVInputsSizeMismatch { expected, actual } => {
write!(f, "expected {expected} cv inputs but found {actual}")
}
RunError::CVOutputsSizeMismatch { expected, actual } => write!(
f,
"cv output required at least {expected} samples but has {actual}",
),
}
}
}