pub struct ProgramGraphRun<'def> { /* private fields */ }Expand description
Representation of a PG that can be executed transition-by-transition.
The structure of the PG cannot be changed,
meaning that it is not possible to introduce new locations, actions, variables, etc.
Though, this restriction makes it so that cloning the ProgramGraphRun is cheap,
because only the internal state needs to be duplicated.
Implementations§
Source§impl<'def> ProgramGraphRun<'def>
impl<'def> ProgramGraphRun<'def>
Sourcepub fn new(program_graph: &'def ProgramGraph) -> Self
pub fn new(program_graph: &'def ProgramGraph) -> Self
Create a new executions from a given PG definition.
Sourcepub fn current_states(&self) -> &[Location]
pub fn current_states(&self) -> &[Location]
Returns the current location.
// Create a new PG builder
let mut pg_builder = ProgramGraphBuilder::new();
// The builder is initialized with an initial location
let initial_loc = pg_builder.new_initial_location();
// Build the PG from its builder
// The builder is always guaranteed to build a well-defined PG and building cannot fail
let pg = pg_builder.build();
let instance = pg.new_instance();
// Execution starts in the initial location
assert_eq!(instance.current_states().as_slice(), &[initial_loc]);Sourcepub fn possible_transitions(
&self,
) -> impl Iterator<Item = (Action, impl Iterator<Item = impl Iterator<Item = Location>>)>
pub fn possible_transitions( &self, ) -> impl Iterator<Item = (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 required action and the post-state (the pre-state being necessarily the current state of the machine). The guard (if any) is guaranteed to be satisfied.
Sourcepub fn nosync_possible_transitions(
&self,
) -> Result<impl Iterator<Item = (Action, impl Iterator<Item = Location>)>, PgError>
pub fn nosync_possible_transitions( &self, ) -> Result<impl Iterator<Item = (Action, impl Iterator<Item = Location>)>, PgError>
Iterates over all transitions that can be admitted in the current state, optimized for the special (but common) case in which the state is given by a single location.
An admissible transition is characterized by the required action and the post-state (the pre-state being necessarily the current state of the machine). The guard (if any) is guaranteed to be satisfied.
Returns error if the state is not given by a single location.
Sourcepub fn transition<R: Rng>(
&mut self,
action: Action,
post_states: &[Location],
rng: &mut R,
) -> Result<(), PgError>
pub fn transition<R: Rng>( &mut self, action: Action, post_states: &[Location], rng: &mut R, ) -> Result<(), PgError>
Executes a transition characterized by the argument action and post-state.
Fails if the requested transition is not admissible, or if the post-location time invariants are violated.
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 wait(&mut self, delta: Time) -> Result<(), PgError>
pub fn wait(&mut self, delta: Time) -> Result<(), PgError>
Waits a given amount of time-units.
Returns error if the waiting would violate the current location’s time invariant (if any).
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,
either because of a temporal guard on the transition becoming true, or a time invariant on the post-location becoming true.
Trait Implementations§
Source§impl<'def> Clone for ProgramGraphRun<'def>
impl<'def> Clone for ProgramGraphRun<'def>
Auto Trait Implementations§
impl<'def> !Freeze for ProgramGraphRun<'def>
impl<'def> !RefUnwindSafe for ProgramGraphRun<'def>
impl<'def> !Sync for ProgramGraphRun<'def>
impl<'def> !UnwindSafe for ProgramGraphRun<'def>
impl<'def> Send for ProgramGraphRun<'def>
impl<'def> Unpin for ProgramGraphRun<'def>
impl<'def> UnsafeUnpin for ProgramGraphRun<'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