pub struct TransitionContext { /* private fields */ }Expand description
Context provided to transition actions.
Provides filtered access based on structure:
- Input places (consumed tokens)
- Read places (context tokens, not consumed)
- Output places (where to produce tokens)
Enforces the structure contract — actions can only access places declared in the transition’s structure.
Implementations§
Source§impl TransitionContext
impl TransitionContext
pub fn new( transition_name: Arc<str>, inputs: HashMap<Arc<str>, Vec<ErasedToken>>, reads: HashMap<Arc<str>, Vec<ErasedToken>>, allowed_outputs: HashSet<Arc<str>>, log_fn: Option<LogFn>, ) -> Self
Sourcepub fn input<T: Send + Sync + 'static>(
&self,
place_name: &str,
) -> Result<Arc<T>, ActionError>
pub fn input<T: Send + Sync + 'static>( &self, place_name: &str, ) -> Result<Arc<T>, ActionError>
Get single consumed input value. Returns error if place not declared or wrong type.
Sourcepub fn inputs<T: Send + Sync + 'static>(
&self,
place_name: &str,
) -> Result<Vec<Arc<T>>, ActionError>
pub fn inputs<T: Send + Sync + 'static>( &self, place_name: &str, ) -> Result<Vec<Arc<T>>, ActionError>
Get all consumed input values for a place.
Sourcepub fn input_raw(
&self,
place_name: &str,
) -> Result<Arc<dyn Any + Send + Sync>, ActionError>
pub fn input_raw( &self, place_name: &str, ) -> Result<Arc<dyn Any + Send + Sync>, ActionError>
Get the raw (type-erased) value of the first input token.
Sourcepub fn input_place_names(&self) -> Vec<Arc<str>>
pub fn input_place_names(&self) -> Vec<Arc<str>>
Returns the names of all declared input places.
Sourcepub fn read<T: Send + Sync + 'static>(
&self,
place_name: &str,
) -> Result<Arc<T>, ActionError>
pub fn read<T: Send + Sync + 'static>( &self, place_name: &str, ) -> Result<Arc<T>, ActionError>
Get read-only context value. Returns error if place not declared.
Sourcepub fn reads<T: Send + Sync + 'static>(
&self,
place_name: &str,
) -> Result<Vec<Arc<T>>, ActionError>
pub fn reads<T: Send + Sync + 'static>( &self, place_name: &str, ) -> Result<Vec<Arc<T>>, ActionError>
Get all read-only context values for a place.
Sourcepub fn read_place_names(&self) -> Vec<Arc<str>>
pub fn read_place_names(&self) -> Vec<Arc<str>>
Returns the names of all declared read places.
Sourcepub fn output<T: Send + Sync + 'static>(
&mut self,
place_name: &str,
value: T,
) -> Result<(), ActionError>
pub fn output<T: Send + Sync + 'static>( &mut self, place_name: &str, value: T, ) -> Result<(), ActionError>
Add output value. Returns error if place not declared as output.
Sourcepub fn output_raw(
&mut self,
place_name: &str,
value: Arc<dyn Any + Send + Sync>,
) -> Result<(), ActionError>
pub fn output_raw( &mut self, place_name: &str, value: Arc<dyn Any + Send + Sync>, ) -> Result<(), ActionError>
Add a raw (type-erased) output value.
Sourcepub fn output_place_names(&self) -> Vec<Arc<str>>
pub fn output_place_names(&self) -> Vec<Arc<str>>
Returns the names of all declared output places.
Sourcepub fn transition_name(&self) -> &str
pub fn transition_name(&self) -> &str
Returns the transition name.
Sourcepub fn set_execution_context<T: Send + Sync + 'static>(
&mut self,
key: &str,
value: T,
)
pub fn set_execution_context<T: Send + Sync + 'static>( &mut self, key: &str, value: T, )
Store an execution context value.
Sourcepub fn execution_context<T: 'static>(&self, key: &str) -> Option<&T>
pub fn execution_context<T: 'static>(&self, key: &str) -> Option<&T>
Retrieve an execution context value.
Sourcepub fn has_execution_context(&self, key: &str) -> bool
pub fn has_execution_context(&self, key: &str) -> bool
Check if an execution context key exists.
Sourcepub fn take_outputs(&mut self) -> Vec<OutputEntry>
pub fn take_outputs(&mut self) -> Vec<OutputEntry>
Collects all output entries (used by executor).
Sourcepub fn take_inputs(&mut self) -> HashMap<Arc<str>, Vec<ErasedToken>>
pub fn take_inputs(&mut self) -> HashMap<Arc<str>, Vec<ErasedToken>>
Reclaims the inputs HashMap for reuse (used by executor to avoid per-firing allocation).
Sourcepub fn take_reads(&mut self) -> HashMap<Arc<str>, Vec<ErasedToken>>
pub fn take_reads(&mut self) -> HashMap<Arc<str>, Vec<ErasedToken>>
Reclaims the reads HashMap for reuse (used by executor to avoid per-firing allocation).
Sourcepub fn outputs(&self) -> &[OutputEntry]
pub fn outputs(&self) -> &[OutputEntry]
Returns a reference to the output entries.