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
impl Marking
pub fn new() -> Self
Sourcepub fn add<T: Send + Sync + 'static>(
&mut self,
place: &Place<T>,
token: Token<T>,
)
pub fn add<T: Send + Sync + 'static>( &mut self, place: &Place<T>, token: Token<T>, )
Adds a typed token to a place.
Sourcepub fn add_erased(&mut self, place_name: &Arc<str>, token: ErasedToken)
pub fn add_erased(&mut self, place_name: &Arc<str>, token: ErasedToken)
Adds a type-erased token to a place by name.
Sourcepub fn has_tokens(&self, place_name: &str) -> bool
pub fn has_tokens(&self, place_name: &str) -> bool
Returns true if a place has any tokens.
Sourcepub fn peek<T: Send + Sync + 'static>(&self, place: &Place<T>) -> Option<Arc<T>>
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.
Sourcepub fn remove_first(&mut self, place_name: &str) -> Option<ErasedToken>
pub fn remove_first(&mut self, place_name: &str) -> Option<ErasedToken>
Removes and returns the first token from a place (FIFO).
Sourcepub fn remove_matching(
&mut self,
place_name: &str,
guard: &dyn Fn(&dyn Any) -> bool,
) -> Option<ErasedToken>
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.
Sourcepub fn remove_all(&mut self, place_name: &str) -> Vec<ErasedToken>
pub fn remove_all(&mut self, place_name: &str) -> Vec<ErasedToken>
Removes and returns all tokens from a place.
Sourcepub fn remove_all_matching(
&mut self,
place_name: &str,
guard: &dyn Fn(&dyn Any) -> bool,
) -> Vec<ErasedToken>
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.
Sourcepub fn count_matching(
&self,
place_name: &str,
guard: &dyn Fn(&dyn Any) -> bool,
) -> usize
pub fn count_matching( &self, place_name: &str, guard: &dyn Fn(&dyn Any) -> bool, ) -> usize
Counts tokens matching a guard predicate.
Sourcepub fn token_counts(&self) -> HashMap<Arc<str>, usize>
pub fn token_counts(&self) -> HashMap<Arc<str>, usize>
Returns the internal token map (for snapshot/event purposes).
Sourcepub fn non_empty_places(&self) -> Vec<Arc<str>>
pub fn non_empty_places(&self) -> Vec<Arc<str>>
Returns all place names that have tokens.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Marking
impl !RefUnwindSafe for Marking
impl Send for Marking
impl Sync for Marking
impl Unpin for Marking
impl UnsafeUnpin for Marking
impl !UnwindSafe for Marking
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
Mutably borrows from an owned value. Read more