Skip to main content

StateEnvelope

Struct StateEnvelope 

Source
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>

Source

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
Source

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.

Source

pub const fn timeline(&self) -> &StateTimeline<S>

The timeline the envelope was built on.

Trait Implementations§

Source§

impl<'a, S: Clone + Storage> Clone for StateEnvelope<'a, S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, S: Debug + Storage> Debug for StateEnvelope<'a, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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>

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.