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 current_states(&self) -> &SmallVec<[Location; 8]>
pub fn current_states(&self) -> &SmallVec<[Location; 8]>
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 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.
Trait Implementations§
Source§impl<'def> Clone for ProgramGraphRun<'def>
impl<'def> Clone for ProgramGraphRun<'def>
Source§fn clone(&self) -> ProgramGraphRun<'def>
fn clone(&self) -> ProgramGraphRun<'def>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<'def> Freeze for ProgramGraphRun<'def>
impl<'def> RefUnwindSafe for ProgramGraphRun<'def>
impl<'def> Send for ProgramGraphRun<'def>
impl<'def> Sync for ProgramGraphRun<'def>
impl<'def> Unpin for ProgramGraphRun<'def>
impl<'def> UnsafeUnpin for ProgramGraphRun<'def>
impl<'def> UnwindSafe 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