pub struct ChannelSystem { /* private fields */ }Expand description
A definition object for a CS. It represents the abstract definition of a CS.
The only way to produce a ChannelSystem is through a ChannelSystemBuilder.
This guarantees that there are no type errors involved in the definition of its PGs,
and thus the CS will always be in a consistent state.
The only way to execute the ChannelSystem is to generate a new ChannelSystemRun through ChannelSystem::new_instance.
The ChannelSystemRun cannot outlive its ChannelSystem, as it holds references to it.
This allows to cheaply generate multiple ChannelSystemRuns from the same ChannelSystem.
Example:
// Create and populate a CS builder object
let mut cs_builder = ChannelSystemBuilder::new();
let pg_id = cs_builder.new_program_graph();
let initial = cs_builder.new_initial_location(pg_id).expect("create new location");
cs_builder.add_autonomous_transition(pg_id, initial, initial, None).expect("add transition");
// Build the builder object to get a CS definition object.
let cs_def = cs_builder.build();
// Instantiate a CS with the previously built definition.
let mut cs = cs_def.new_instance();
// Perform the (unique) active transition available.
let (pg_id_trans, e, mut post_locs) = cs.possible_transitions().last().expect("autonomous transition");
assert_eq!(pg_id_trans, pg_id);
let post_loc = post_locs.last().expect("post location").last().expect("post location");
assert_eq!(post_loc, initial);
cs.transition(pg_id, e, &[initial]).expect("transition is active");Implementations§
Source§impl ChannelSystem
impl ChannelSystem
Sourcepub fn new_instance<'def>(&'def self) -> ChannelSystemRun<'def>
pub fn new_instance<'def>(&'def self) -> ChannelSystemRun<'def>
Creates a new ChannelSystemRun which allows to execute the CS as defined.
The new instance borrows the caller to refer to the CS definition without copying its data, so that spawning instances is (relatively) inexpensive.
See also ProgramGraph::new_instance.
Sourcepub fn program_graphs(&self) -> &[ProgramGraph]
pub fn program_graphs(&self) -> &[ProgramGraph]
Returns an immutable reference to the list of ProgramGraphs of the Channel System.
Sourcepub fn program_graph_ids(&self) -> impl Iterator<Item = PgId>
pub fn program_graph_ids(&self) -> impl Iterator<Item = PgId>
Returns the list of PgIds associated to the Program Graphs of the Channel System.
Sourcepub fn channels(&self) -> &[(Vec<Type>, ChannelCapacity)]
pub fn channels(&self) -> &[(Vec<Type>, ChannelCapacity)]
Returns the list of defined channels, given as the pair of their type and capacity
(where None denotes channels with infinite capacity, and Some denotes channels with finite capacity).
Trait Implementations§
Source§impl Clone for ChannelSystem
impl Clone for ChannelSystem
Source§fn clone(&self) -> ChannelSystem
fn clone(&self) -> ChannelSystem
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChannelSystem
impl Debug for ChannelSystem
Source§impl GetSize for ChannelSystem
impl GetSize for ChannelSystem
Source§fn get_heap_size(&self) -> usize
fn get_heap_size(&self) -> usize
Source§fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>(
&self,
tracker: TRACKER,
) -> (usize, TRACKER)
fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>( &self, tracker: TRACKER, ) -> (usize, TRACKER)
tracker. Read moreSource§fn get_stack_size() -> usize
fn get_stack_size() -> usize
Source§fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
tracker. Read moreAuto Trait Implementations§
impl Freeze for ChannelSystem
impl RefUnwindSafe for ChannelSystem
impl Send for ChannelSystem
impl Sync for ChannelSystem
impl Unpin for ChannelSystem
impl UnsafeUnpin for ChannelSystem
impl UnwindSafe for ChannelSystem
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