pub struct CausalState<I, O, C>{ /* private fields */ }Expand description
A CausalState represents a state in a causal state machine (CSM) that can be evaluated
based on causal conditions.
In a CSM, states are paired with actions. When a state’s conditions are met (evaluated to true), the associated action is triggered.
§Purpose
CausalState encapsulates a reference to a causaloid that defines when the state should be
considered active, along with:
- An identifier for the state
- A version number for tracking changes
- Data that can be used for evaluation
§Usage
CausalState is typically used in conjunction with CausalAction in a state-action pair
within a causal state machine (CSM). The CSM evaluates states, and when conditions are met,
fires the associated actions.
Implementations§
Source§impl<I, O, C> CausalState<I, O, C>
impl<I, O, C> CausalState<I, O, C>
Sourcepub fn eval(&self) -> Result<PropagatingEffect<O>, CsmError>
pub fn eval(&self) -> Result<PropagatingEffect<O>, CsmError>
Evaluates the state using its internal data.
This method uses the state’s causaloid to determine if the state’s conditions are met based on the internal data value.
§Returns
Ok(PropagatingEffect<O>)if evaluation succeedsErr(CausalStateError)if an error occurs during evaluation
Sourcepub fn eval_with_data(
&self,
data: &PropagatingEffect<I>,
) -> Result<PropagatingEffect<O>, CsmError>
pub fn eval_with_data( &self, data: &PropagatingEffect<I>, ) -> Result<PropagatingEffect<O>, CsmError>
Evaluates the state using provided external data.
This method uses the state’s causaloid to determine if the state’s conditions are met based on the provided data value, rather than the internal data.
§Parameters
data: The numerical value to use for evaluation
§Returns
Ok(PropagatingEffect<O>)if evaluation succeedsErr(CsmError)if an error occurs during evaluation
Source§impl<I, O, C> CausalState<I, O, C>
impl<I, O, C> CausalState<I, O, C>
Trait Implementations§
Source§impl<I, O, C> Clone for CausalState<I, O, C>
impl<I, O, C> Clone for CausalState<I, O, C>
Source§fn clone(&self) -> CausalState<I, O, C>
fn clone(&self) -> CausalState<I, O, C>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more