#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum BitDepth {
Eight,
Sixteen,
Float32,
Unknown
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum BitType {
U8,
U16,
F32
}
impl BitType {
pub fn to_depth(self) -> BitDepth {
match self {
BitType::U8 => BitDepth::Eight,
BitType::U16 => BitDepth::Sixteen,
BitType::F32 => BitDepth::Float32
}
}
}
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::Sixteen => u16::MAX,
Self::Float32 => 1,
Self::Unknown => 0,
}
}
pub const fn bit_type(self) -> BitType {
match self {
Self::Eight => BitType::U8,
Self::Sixteen => BitType::U16,
Self::Float32 => BitType::F32,
Self::Unknown => panic!("Unknown bit type")
}
}
pub const fn size_of(self) -> usize {
match self {
Self::Eight => core::mem::size_of::<u8>(),
Self::Sixteen => core::mem::size_of::<u16>(),
Self::Float32 => core::mem::size_of::<f32>(),
Self::Unknown => panic!("Unknown bit type")
}
}
pub const fn bit_size(&self) -> usize {
self.size_of() * 8
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum ByteEndian {
LE,
BE
}