use thiserror::Error;
use winnow::error::ContextError;
use crate::hps::COEFFICIENT_PAIRS_PER_CHANNEL;
#[derive(Error, Debug)]
pub enum HpsParseError {
#[error("Invalid magic number. Expected ' HALPST\0'")]
InvalidMagicNumber,
#[error("Only stereo is supported, but the provided file has {0} audio channel(s)")]
UnsupportedChannelCount(u32),
#[error("Tried to parse, but encountered invalid data. Cause: {}",
match .0.cause() {
Some(cause) => cause.to_string(),
None => "None".to_string()
})]
InvalidData(ContextError),
}
impl From<ContextError> for HpsParseError {
fn from(error: ContextError) -> Self {
HpsParseError::InvalidData(error)
}
}
#[derive(Error, Debug)]
pub enum HpsDecodeError {
#[error(
"One of the audio frame headers contains a coefficient index of {0} which is invalid. Length of the coefficients array is {COEFFICIENT_PAIRS_PER_CHANNEL}"
)]
InvalidCoefficientIndex(usize),
}