#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[non_exhaustive]
pub enum AacAdditionalInfo {
AacData,
AacWithBandwidthExtension,
Reserved(u8),
}
impl AacAdditionalInfo {
#[must_use]
pub fn from_u8(v: u8) -> Self {
match v {
0x00 => Self::AacData,
0x01 => Self::AacWithBandwidthExtension,
v => Self::Reserved(v),
}
}
#[must_use]
pub const fn to_u8(self) -> u8 {
match self {
Self::AacData => 0x00,
Self::AacWithBandwidthExtension => 0x01,
Self::Reserved(v) => v,
}
}
#[must_use]
pub fn name(self) -> &'static str {
match self {
Self::AacData => "AAC data",
Self::AacWithBandwidthExtension => "AAC with bandwidth extension",
Self::Reserved(_) => "reserved",
}
}
}
broadcast_common::impl_spec_display!(AacAdditionalInfo, Reserved);
#[cfg(test)]
mod tests {
use super::*;
use alloc::string::ToString;
#[test]
fn labels_match_table_2_95() {
assert_eq!(AacAdditionalInfo::AacData.name(), "AAC data");
assert_eq!(
AacAdditionalInfo::AacWithBandwidthExtension.name(),
"AAC with bandwidth extension"
);
assert_eq!(AacAdditionalInfo::Reserved(0x02).name(), "reserved");
assert_eq!(AacAdditionalInfo::AacData.to_string(), "AAC data");
assert_eq!(
AacAdditionalInfo::Reserved(0x02).to_string(),
"reserved(0x02)"
);
}
}