use std::ops::{Deref, DerefMut};
#[repr(u32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Interpretation {
Whole,
Decimal { multiplier: u32 },
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FastVolume(i64);
impl FastVolume {
pub fn as_whole_i64(
self,
) -> i64 {
self.0
}
pub fn as_interpreted_f64(
self,
interpretation: Interpretation,
) -> f64 {
match interpretation {
Interpretation::Whole => self.0 as f64,
Interpretation::Decimal {
multiplier,
} => self.0 as f64 * multiplier as f64,
}
}
}
impl Deref for FastVolume {
type Target = i64;
fn deref(
&self,
) -> &Self::Target {
&self.0
}
}
impl DerefMut for FastVolume {
fn deref_mut(
&mut self,
) -> &mut Self::Target {
&mut self.0
}
}