Expand description
§libpetri — Coloured Time Petri Net Engine
A high-performance Petri net engine with formal verification support.
§Quick Start
use libpetri::*;
let p1 = Place::<i32>::new("input");
let p2 = Place::<i32>::new("output");
let t = Transition::builder("process")
.input(one(&p1))
.output(out_place(&p2))
.action(fork())
.build();
let net = PetriNet::builder("example").transition(t).build();
let mut marking = Marking::new();
marking.add(&p1, Token::at(42, 0));
let mut executor = BitmapNetExecutor::<NoopEventStore>::new(
&net, marking, ExecutorOptions::default(),
);
executor.run_sync();
assert_eq!(*executor.marking().peek(&p2).unwrap(), 42);§Example: Basic Chain
§Example: Order Processing Pipeline
A showcase net demonstrating all arc types (input, output, read, inhibitor, reset), both place types (regular + environment), all timing modes (immediate, deadline, delayed, window, exact), and patterns (AND-fork, AND-join, XOR, priority).
§Crate Structure
core— Places, tokens, transitions, timing, actionsevent— Event store for recording execution eventsruntime— Bitmap-based executor (sync + async)export— DOT/Graphviz export pipelineverification— Formal verification (P-invariants, state class graphs, SMT)
Re-exports§
pub use libpetri_core as core;pub use libpetri_event as event;pub use libpetri_export as export;pub use libpetri_runtime as runtime;pub use libpetri_verification as verification;
Structs§
- Action
Error - Error returned by transition actions.
- Bitmap
NetExecutor - Bitmap-based executor for Coloured Time Petri Nets.
- Compiled
Net - Integer-indexed, precomputed representation of a PetriNet for bitmap-based execution.
- Environment
Place - An environment place that accepts external token injection. Wraps a regular Place and marks it for external event injection.
- Executor
Options - Options for constructing a BitmapNetExecutor.
- InMemory
Event Store - In-memory event store for debugging and testing.
- Inhibitor
- Inhibitor arc: blocks transition if place has tokens.
- Marking
- Mutable token state of a Petri net during execution.
- Noop
Event Store - No-op event store for production use.
- Petri
Net - Immutable definition of a Time Petri Net structure.
- Place
- A typed place in the Petri Net that holds tokens of a specific type.
- Place
Ref - Type-erased reference to a place, used internally for arc storage.
- Precompiled
Executor Builder - Builder for PrecompiledNetExecutor.
- Precompiled
Net - Precompiled flat-array net representation for the
super::precompiled_executor::PrecompiledNetExecutor. - Precompiled
NetExecutor - High-performance precompiled flat-array Petri net executor.
- Read
- Read arc: requires token without consuming.
- Reset
- Reset arc: removes all tokens from place when firing.
- Token
- An immutable token carrying a typed value through the Petri net.
- Transition
- A transition in the Time Petri Net that transforms tokens.
- Transition
Context - Context provided to transition actions.
Enums§
- In
- Input specification with cardinality and optional guard predicate.
- NetEvent
- All observable events during Petri net execution.
- Out
- Output specification with explicit split semantics.
- Timing
- Firing timing specification for transitions.
Traits§
- Event
Store - Trait for event storage during Petri net execution.
Functions§
- all
- Consume all available tokens (must be 1+).
- and
- AND-split: all children must receive tokens.
- and_
places - AND-split from places: all places must receive tokens.
- async_
action - Creates an action from an async closure.
- at_
least - Wait for N+ tokens, consume all when enabled.
- deadline
- Immediate with deadline: can fire immediately, must fire by deadline.
- delayed
- Delayed firing: must wait, then can fire anytime.
- dot_
export - Convenience function: maps a PetriNet to DOT format string.
- exact
- Exact timing: fires at precisely the specified time.
- exactly
- Consume exactly N tokens from the place.
- fork
- Fork action: copies single input token to all outputs.
- forward_
input - Forward consumed input value to output place on timeout.
- immediate
- Immediate firing: can fire as soon as enabled, no deadline.
- inhibitor
- Creates an inhibitor arc for the given place.
- one
- Consume exactly 1 token from the place.
- out_
place - Leaf output spec for a single place.
- passthrough
- Identity action: produces no outputs. Executes synchronously.
- produce
- Produce action: produces a single token with the given value to the specified place.
- read
- Creates a read arc for the given place.
- reset
- Creates a reset arc for the given place.
- sync_
action - Creates an action from a synchronous closure.
- timeout
- Timeout output: activates if action exceeds duration.
- timeout_
place - Timeout output pointing to a single place.
- transform
- Transform action: applies function to context, copies result to ALL output places.
- window
- Time window: can fire within [earliest, latest].
- xor
- XOR-split: exactly one child receives token.
- xor_
places - XOR-split from places: exactly one place receives token.
Type Aliases§
- Boxed
Action - Type alias for boxed transition actions.