use super::{
PreemptionBound, PreemptionBounds, PreemptionBoundsRefusal, PreemptionModelFailure,
PreemptionOutcome, PreemptionReading,
};
use crate::report::ForeignText;
impl PreemptionBounds {
pub const fn declared(
preemptions: PreemptionBound,
branches: u32,
) -> Result<Self, PreemptionBoundsRefusal> {
if branches == 0u32 {
return Err(PreemptionBoundsRefusal::ZeroBranches);
}
Ok(Self {
preemptions,
branches,
})
}
#[must_use]
pub const fn preemptions(self) -> PreemptionBound {
self.preemptions
}
#[must_use]
pub const fn branches(self) -> u32 {
self.branches
}
}
impl PreemptionModelFailure {
#[must_use]
pub const fn unreported() -> Self {
Self { report: None }
}
#[must_use]
pub fn reported(material: &[u8]) -> Self {
Self {
report: Some(ForeignText::admitted(material)),
}
}
#[must_use]
pub const fn report(&self) -> Option<&ForeignText> {
self.report.as_ref()
}
}
impl PreemptionReading {
#[must_use]
pub(crate) const fn read(bounds: PreemptionBounds, outcome: PreemptionOutcome) -> Self {
Self { bounds, outcome }
}
#[must_use]
pub const fn bounds(&self) -> PreemptionBounds {
self.bounds
}
#[must_use]
pub const fn outcome(&self) -> &PreemptionOutcome {
&self.outcome
}
}