#[cfg(feature = "alloc")]
use crate::storage::Heap;
use crate::storage::Storage;
use crate::{ActivityId, Level, Tick};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Bound {
BelowMin(Level),
AboveMax(Level),
BelowTarget(Level),
}
impl Bound {
#[must_use]
pub const fn is_lower(&self) -> bool {
matches!(self, Self::BelowMin(_) | Self::BelowTarget(_))
}
#[must_use]
pub const fn value(&self) -> Level {
match *self {
Self::BelowMin(value) | Self::AboveMax(value) | Self::BelowTarget(value) => value,
}
}
pub(crate) const fn is_pushed_by(&self, effect: i128) -> bool {
if self.is_lower() {
effect < 0
} else {
effect > 0
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Violation<
#[cfg(feature = "alloc")] S: Storage = Heap,
#[cfg(not(feature = "alloc"))] S: Storage,
> {
pub at: Tick,
pub level: Level,
pub bound: Bound,
pub contributors: S::List<ActivityId>,
}