Net

Struct Net 

Source
pub struct Net { /* private fields */ }
Expand description

A Colored Petri Net (CPN).

Implementations§

Source§

impl Net

Source

pub fn new(name: &str) -> Self

Constructs an empty, top-level net.

Source

pub fn default(name: &str) -> Self

👎Deprecated

Constructs an empty, top-level net.

Source

pub fn seed_rng(&mut self, seed: u64)

Seed (or re-seed) the PRNG.

This may be desirable to enable reproducible simulations.

Source

pub fn name(&self) -> &str

Get the net’s name.

Source

pub fn add_place<P>(&mut self, place: P) -> Result<()>
where P: Into<Place>,

Add a place with the given name to the net.

Source

pub fn add_places<P, I>(&mut self, places: I) -> Result<()>
where P: Into<Place>, I: IntoIterator<Item = P>,

Add multiple places at once.

Source

pub fn places(&self) -> impl Iterator<Item = &Place>

Get an iterator over references of the contained places.

Source

pub fn add_transition(&mut self, transition: Transition) -> Result<()>

Add the given transition to the net.

After it has been added, use add_arc to connect it to places.

Source

pub fn add_in_arc(&mut self, from: &str, to: &str, binding: &str) -> Result<()>

Add an arc from the place to the transition.

Source

pub fn add_out_arc( &mut self, from: &str, to: &str, expression: Expression, ) -> Result<()>

Add an arc from the transition to the place.

Source

pub fn add_arcs<'a, I>(&mut self, specs: I) -> Result<()>
where I: IntoIterator<Item = ArcSpec<'a>>,

Add multiple arcs at once.

This function is intended to be used together with the arcs! macro.

Source

pub fn empty_marking(&self) -> Marking

Create an empty marking for this net.

Source

pub fn simulation_step( &mut self, marking: &mut Marking, allow_non_determinism: bool, ) -> Result<()>

Perform one step in a net simulation, given the marking marking.

Source

pub fn run_simulation( &mut self, marking: &mut Marking, allow_non_determinism: bool, ) -> Result<()>

Repeatedly call simulation_step until the net is dead.

Trait Implementations§

Source§

impl Debug for Net

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl DumpDot for Net

Source§

fn to_dot_string(&self) -> String

Build a String containing a DOT representation of self.
Source§

fn dump_dot(&self)

Dump the DOT representation of self to stdout.

Auto Trait Implementations§

§

impl Freeze for Net

§

impl !RefUnwindSafe for Net

§

impl !Send for Net

§

impl !Sync for Net

§

impl Unpin for Net

§

impl !UnwindSafe for Net

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V