use std::convert::TryFrom;
use std::fmt;
#[derive(Debug, Copy, Clone)]
#[repr(u32)]
pub enum Quantization {
Default = 0,
FullRange = 1,
LimitedRange = 2,
}
impl fmt::Display for Quantization {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Default => write!(f, "default"),
Self::FullRange => write!(f, "full range"),
Self::LimitedRange => write!(f, "limited range"),
}
}
}
impl TryFrom<u32> for Quantization {
type Error = ();
fn try_from(code: u32) -> Result<Self, Self::Error> {
match code {
0 => Ok(Self::Default),
1 => Ok(Self::FullRange),
2 => Ok(Self::LimitedRange),
_ => Err(()),
}
}
}