pub struct StateEnvelope<'a, S: Storage = Heap> { /* private fields */ }Expand description
The state envelope of a state timeline with additional flexible activities.
The timeline’s own impacts count as fixed.
§Examples
use resource_timeline::envelope::{FlexibleState, StateEnvelope, StateVerdict};
use resource_timeline::{ActivityId, StateImpact, StateTimeline, Window};
const COLD: u32 = 0;
const WARM: u32 = 1;
// The heater warms the instrument at its start; the analysis needs it warm for 5 ticks.
let instrument = StateTimeline::new(0, COLD, 8);
let heat = [StateImpact::Set { at: 0, value: WARM }];
let analyze = [StateImpact::Require { start: 0, end: 5, value: WARM }];
let flexible = [
FlexibleState { activity: ActivityId(1), window: Window::new(0, 10)?, impacts: &heat },
FlexibleState { activity: ActivityId(2), window: Window::new(10, 20)?, impacts: &analyze },
];
assert_eq!(StateEnvelope::new(&instrument, &flexible)?.check()?, StateVerdict::Safe);
// If the analysis may start first, some schedule finds the instrument cold.
let early = [flexible[0], FlexibleState { window: Window::new(5, 20)?, ..flexible[1] }];
assert!(matches!(
StateEnvelope::new(&instrument, &early)?.check()?,
StateVerdict::Possible(_)
));Implementations§
Source§impl<'a, S: Storage> StateEnvelope<'a, S>
impl<'a, S: Storage> StateEnvelope<'a, S>
Sourcepub fn new(
timeline: &'a StateTimeline<S>,
flexible: &'a [FlexibleState<'a>],
) -> Result<Self, Error>
pub fn new( timeline: &'a StateTimeline<S>, flexible: &'a [FlexibleState<'a>], ) -> Result<Self, Error>
Combines the fixed impacts of timeline with the flexible activities.
§Errors
- The validation errors of
StateTimeline::addfor any flexible impact at the earliest or latest start of its window. Error::Overflowif a shifted tick does not fit aTick.Error::OutOfMemoryif the activity lists cannot be allocated.
Sourcepub fn check(&self) -> Result<StateVerdict, Error>
pub fn check(&self) -> Result<StateVerdict, Error>
Checks every requirement and every pair of sets over all admitted schedules.
A certain violation anywhere takes precedence over possible ones. At the same tick a conflict is reported before a mismatch, and among mismatches the smallest requirer.
§Errors
Error::OutOfMemory if the working memory cannot be allocated.
Sourcepub const fn timeline(&self) -> &StateTimeline<S>
pub const fn timeline(&self) -> &StateTimeline<S>
The timeline the envelope was built on.
Trait Implementations§
Auto Trait Implementations§
impl<'a, S> Forget for StateEnvelope<'a, S>
impl<'a, S> Freeze for StateEnvelope<'a, S>where
&'a StateTimeline<S>: Freeze,
impl<'a, S> Move for StateEnvelope<'a, S>
impl<'a, S> RefUnwindSafe for StateEnvelope<'a, S>where
&'a StateTimeline<S>: RefUnwindSafe,
impl<'a, S> Send for StateEnvelope<'a, S>where
&'a StateTimeline<S>: Send,
impl<'a, S> Sync for StateEnvelope<'a, S>where
&'a StateTimeline<S>: Sync,
impl<'a, S> Unpin for StateEnvelope<'a, S>where
&'a StateTimeline<S>: Unpin,
impl<'a, S> UnsafeUnpin for StateEnvelope<'a, S>where
&'a StateTimeline<S>: UnsafeUnpin,
impl<'a, S> UnwindSafe for StateEnvelope<'a, S>where
&'a StateTimeline<S>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more