use super::Ratio;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Pull(Ratio);
impl Pull {
pub const NONE: Self = Self(Ratio::from_integer(1));
pub const UP_0_1_PERCENT: Self = Self(Ratio::reduced(1001, 1000));
pub const DOWN_0_1_PERCENT: Self = Self(Ratio::reduced(1000, 1001));
pub const UP_4_PERCENT: Self = Self(Ratio::reduced(25, 24));
pub const DOWN_4_PERCENT: Self = Self(Ratio::reduced(24, 25));
pub const fn factor(self) -> Ratio {
self.0
}
pub const fn then(self, next: Self) -> Option<Self> {
match self.0.checked_mul(next.0) {
Some(factor) => Some(Self(factor)),
None => None,
}
}
pub const fn apply(self, rate: Ratio) -> Option<Ratio> {
rate.checked_mul(self.0)
}
}