pub struct ProgramGraph { /* private fields */ }Expand description
A definition object for a PG. It represents the abstract definition of a PG.
The only way to produce a ProgramGraph is through a ProgramGraphBuilder.
This guarantees that there are no type errors involved in the definition of action’s effects and transitions’ guards,
and thus the PG will always be in a consistent state.
The only way to execute the ProgramGraph is to generate a new ProgramGraphRun through ProgramGraph::new_instance.
The ProgramGraphRun cannot outlive its ProgramGraph, as it holds references to it.
This allows to cheaply generate multiple ProgramGraphRuns from the same ProgramGraph.
Example:
// Create and populate a PG builder object
let mut pg_builder = ProgramGraphBuilder::new();
let initial = pg_builder.new_initial_location();
pg_builder.add_autonomous_transition(initial, initial, None).expect("add transition");
// Build the builder object to get a PG definition object.
let pg_def = pg_builder.build();
// Instantiate a PG with the previously built definition.
let mut pg = pg_def.new_instance();
// Perform the (unique) active transition available.
let (e, mut post_locs) = pg.possible_transitions().last().expect("autonomous transition");
let post_loc = post_locs.last().expect("post location").last().expect("post location");
assert_eq!(post_loc, initial);
let mut rng: SmallRng = rand::make_rng();
pg.transition(e, &[initial], &mut rng).expect("transition is active");Implementations§
Source§impl ProgramGraph
impl ProgramGraph
Sourcepub fn new_instance<'def>(&'def self) -> ProgramGraphRun<'def>
pub fn new_instance<'def>(&'def self) -> ProgramGraphRun<'def>
Creates a new ProgramGraphRun which allows to execute the PG as defined.
The new instance borrows the caller to refer to the PG definition without copying its data, so that spawning instances is (relatively) inexpensive.
Trait Implementations§
Source§impl Clone for ProgramGraph
impl Clone for ProgramGraph
Source§fn clone(&self) -> ProgramGraph
fn clone(&self) -> ProgramGraph
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ProgramGraph
impl RefUnwindSafe for ProgramGraph
impl Send for ProgramGraph
impl Sync for ProgramGraph
impl Unpin for ProgramGraph
impl UnsafeUnpin for ProgramGraph
impl UnwindSafe for ProgramGraph
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