Skip to main content

TransitionContext

Struct TransitionContext 

Source
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

Source

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

Source

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.

Source

pub fn inputs<T: Send + Sync + 'static>( &self, place_name: &str, ) -> Result<Vec<Arc<T>>, ActionError>

Get all consumed input values for a place.

Source

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.

Source

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

Returns the names of all declared input places.

Source

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.

Source

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.

Source

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

Returns the names of all declared read places.

Source

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.

Source

pub fn output_raw( &mut self, place_name: &str, value: Arc<dyn Any + Send + Sync>, ) -> Result<(), ActionError>

Add a raw (type-erased) output value.

Source

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

Returns the names of all declared output places.

Source

pub fn transition_name(&self) -> &str

Returns the transition name.

Source

pub fn set_execution_context<T: Send + Sync + 'static>( &mut self, key: &str, value: T, )

Store an execution context value.

Source

pub fn execution_context<T: 'static>(&self, key: &str) -> Option<&T>

Retrieve an execution context value.

Source

pub fn has_execution_context(&self, key: &str) -> bool

Check if an execution context key exists.

Source

pub fn log(&self, level: &str, message: &str)

Emits a structured log message.

Source

pub fn take_outputs(&mut self) -> Vec<OutputEntry>

Collects all output entries (used by executor).

Source

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

Source

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

Source

pub fn outputs(&self) -> &[OutputEntry]

Returns a reference to the output entries.

Trait Implementations§

Source§

impl Debug for TransitionContext

Source§

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

Formats the value using the given formatter. 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.