#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum BitDepth
{
Eight,
Ten,
Twelve,
Sixteen,
Unknown
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum BitType
{
U8,
U16
}
impl Default for BitDepth
{
fn default() -> Self
{
Self::Unknown
}
}
impl BitDepth
{
#[rustfmt::skip]
#[allow(clippy::zero_prefixed_literal)]
pub const fn max_value(self) -> u16
{
match self
{
Self::Eight => (1 << 08) - 1,
Self::Ten => (1 << 10) - 1,
Self::Twelve => (1 << 12) - 1,
Self::Sixteen => u16::MAX,
Self::Unknown => 0,
}
}
pub const fn bit_type(self) -> BitType
{
match self
{
Self::Eight => BitType::U8,
Self::Ten | Self::Twelve | Self::Sixteen => BitType::U16,
Self::Unknown => panic!("Unknown bit type")
}
}
pub const fn size_of(self) -> usize
{
match self
{
Self::Eight => 1,
Self::Ten | Self::Twelve | Self::Sixteen => 2,
Self::Unknown => panic!("Unknown bit type")
}
}
}