pub struct ChannelSystemRun<'def> { /* private fields */ }Expand description
Representation of a CS that can be executed transition-by-transition.
The structure of the CS cannot be changed,
meaning that it is not possible to introduce new PGs or modifying them, or add new channels.
Though, this restriction makes it so that cloning the ChannelSystem is cheap,
because only the internal state needs to be duplicated.
Implementations§
Source§impl<'def> ChannelSystemRun<'def>
impl<'def> ChannelSystemRun<'def>
Sourcepub fn new(cs: &'def ChannelSystem) -> Self
pub fn new(cs: &'def ChannelSystem) -> Self
Creates a new ChannelSystemRun which allows to execute the CS as defined.
The new instance borrows the ChannelSystem to refer to the CS definition without copying its data,
so that spawning instances is (relatively) inexpensive.
See also ProgramGraphRun::new.
Sourcepub fn def(&self) -> &ChannelSystem
pub fn def(&self) -> &ChannelSystem
Returns a reference to the underlying ChannelSystem defining the execution.
Sourcepub fn program_graph(
&self,
pg_id: PgId,
) -> Result<&ProgramGraphRun<'_>, CsError>
pub fn program_graph( &self, pg_id: PgId, ) -> Result<&ProgramGraphRun<'_>, CsError>
Returns an immutable reference to the ProgramGraphRuns of the Channel System associated to the given PgId.
Sourcepub fn possible_transitions(
&self,
) -> impl Iterator<Item = (PgId, Action, impl Iterator<Item = impl Iterator<Item = Location>>)>
pub fn possible_transitions( &self, ) -> impl Iterator<Item = (PgId, Action, impl Iterator<Item = impl Iterator<Item = Location>>)>
Iterates over all transitions that can be admitted in the current state.
An admissible transition is characterized by the PG it executes on, the required action and the post-state (the pre-state being necessarily the current state of the machine). The (eventual) guard is guaranteed to be satisfied.
See also ProgramGraphRun::possible_transitions.
Sourcepub fn possible_transitions_pg(
&self,
pg_id: PgId,
) -> Result<impl Iterator<Item = (Action, impl Iterator<Item = impl Iterator<Item = Location>>)>, CsError>
pub fn possible_transitions_pg( &self, pg_id: PgId, ) -> Result<impl Iterator<Item = (Action, impl Iterator<Item = impl Iterator<Item = Location>>)>, CsError>
Iterates over all transitions that can be admitted in the current state for the [ProgramGraph] associated to the given PgId.
An admissible transition is characterized by the PG it executes on, the required action and the post-state (the pre-state being necessarily the current state of the machine). The (eventual) guard is guaranteed to be satisfied.
See also ProgramGraphRun::possible_transitions.
Sourcepub fn nosync_possible_transitions_pg(
&self,
pg_id: PgId,
) -> Result<impl Iterator<Item = (Action, impl Iterator<Item = Location>)>, CsError>
pub fn nosync_possible_transitions_pg( &self, pg_id: PgId, ) -> Result<impl Iterator<Item = (Action, impl Iterator<Item = Location>)>, CsError>
Iterates over all transitions that can be admitted in the current state for the [ProgramGraph] associated to the given PgId,
optimized for the special (but common) case in which the state of the PG is given by a single location.
An admissible transition is characterized by the PG it executes on, the required action and the post-state (the pre-state being necessarily the current state of the machine). The (eventual) guard is guaranteed to be satisfied.
Sourcepub fn transition(
&mut self,
pg_id: PgId,
action: Action,
post: &[Location],
) -> Result<Option<Event>, CsError>
pub fn transition( &mut self, pg_id: PgId, action: Action, post: &[Location], ) -> Result<Option<Event>, CsError>
Executes a transition on the given PG characterized by the argument action and post-state.
Fails if the requested transition is not admissible.
See also ProgramGraphRun::transition.
Sourcepub fn wait(&mut self, delta: Time) -> Result<(), CsError>
pub fn wait(&mut self, delta: Time) -> Result<(), CsError>
Tries waiting for the given delta of time. Returns error if any of the PG cannot wait due to some time invariant.
Sourcepub fn can_wait(&self, delta: Time) -> bool
pub fn can_wait(&self, delta: Time) -> bool
Checks if it is possible to wait a given amount of time-units without violating the time invariants.
Sourcepub fn is_waiting(&self) -> bool
pub fn is_waiting(&self) -> bool
Returns true if there is any transition from the current state that will be unlocked at some point in the future.
Trait Implementations§
Source§impl<'def> Clone for ChannelSystemRun<'def>
impl<'def> Clone for ChannelSystemRun<'def>
Auto Trait Implementations§
impl<'def> !Freeze for ChannelSystemRun<'def>
impl<'def> !RefUnwindSafe for ChannelSystemRun<'def>
impl<'def> !Sync for ChannelSystemRun<'def>
impl<'def> !UnwindSafe for ChannelSystemRun<'def>
impl<'def> Send for ChannelSystemRun<'def>
impl<'def> Unpin for ChannelSystemRun<'def>
impl<'def> UnsafeUnpin for ChannelSystemRun<'def>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more