Skip to main content

Marking

Struct Marking 

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

Mutable token state of a Petri net during execution.

Stores type-erased tokens in FIFO queues keyed by place name.

Implementations§

Source§

impl Marking

Source

pub fn new() -> Self

Source

pub fn add<T: Send + Sync + 'static>( &mut self, place: &Place<T>, token: Token<T>, )

Adds a typed token to a place.

Source

pub fn add_erased(&mut self, place_name: &Arc<str>, token: ErasedToken)

Adds a type-erased token to a place by name.

Source

pub fn count(&self, place_name: &str) -> usize

Returns the number of tokens in a place.

Source

pub fn has_tokens(&self, place_name: &str) -> bool

Returns true if a place has any tokens.

Source

pub fn peek<T: Send + Sync + 'static>(&self, place: &Place<T>) -> Option<Arc<T>>

Peeks at the first token value in a place without removing it.

Source

pub fn remove_first(&mut self, place_name: &str) -> Option<ErasedToken>

Removes and returns the first token from a place (FIFO).

Source

pub fn remove_matching( &mut self, place_name: &str, guard: &dyn Fn(&dyn Any) -> bool, ) -> Option<ErasedToken>

Removes and returns the first token matching a guard predicate.

Source

pub fn remove_all(&mut self, place_name: &str) -> Vec<ErasedToken>

Removes and returns all tokens from a place.

Source

pub fn remove_all_matching( &mut self, place_name: &str, guard: &dyn Fn(&dyn Any) -> bool, ) -> Vec<ErasedToken>

Removes and returns all tokens matching a guard predicate.

Source

pub fn count_matching( &self, place_name: &str, guard: &dyn Fn(&dyn Any) -> bool, ) -> usize

Counts tokens matching a guard predicate.

Source

pub fn token_counts(&self) -> HashMap<Arc<str>, usize>

Returns the internal token map (for snapshot/event purposes).

Source

pub fn non_empty_places(&self) -> Vec<Arc<str>>

Returns all place names that have tokens.

Source

pub fn queue(&self, place_name: &str) -> Option<&VecDeque<ErasedToken>>

Returns the raw queue for a place (for executor internal use).

Trait Implementations§

Source§

impl Debug for Marking

Source§

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

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

impl Default for Marking

Source§

fn default() -> Marking

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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, 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.