#[cfg(feature = "std")]
use crate::IoError;
#[cfg(feature = "std")]
use crate::IoErrorKind;
#[doc = crate::_tags!(audio error)]
#[doc = crate::_doc_meta!{location("media/audio"), test_size_of(PcmRawError = 1|8)}]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum PcmRawError {
InvalidSpec,
InvalidDataLength,
MismatchedSampleFormat,
SampleOutOfRange,
NotEnoughSpace,
#[cfg(feature = "std")]
Io(IoErrorKind),
}
crate::impl_trait![fmt::Display+Error for PcmRawError |self, f| match self {
Self::InvalidSpec => f.write_str("invalid raw PCM stream specification"),
Self::InvalidDataLength => {
f.write_str("raw PCM data length is not a multiple of frame size")
}
Self::MismatchedSampleFormat => {
f.write_str("PCM sample format does not match the requested operation")
}
Self::SampleOutOfRange => f.write_str("PCM sample value is outside the target range"),
Self::NotEnoughSpace => f.write_str("not enough space to write raw PCM data"),
#[cfg(feature = "std")]
Self::Io(err) => write!(f, "raw PCM file operation failed: {err}"),
}];
#[cfg(feature = "std")]
impl From<IoError> for PcmRawError {
fn from(err: IoError) -> Self {
Self::Io(err.kind())
}
}