CausalState

Struct CausalState 

Source
pub struct CausalState<I, O, C>
where I: Default, O: Default + Debug, C: Clone,
{ /* 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>
where I: Default + Clone + Debug + Send + Sync, O: CsmEvaluable + Default + Debug + Clone + Send + Sync, C: Clone + Send + Sync, Causaloid<I, O, (), C>: MonadicCausable<I, O>,

Source

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 succeeds
  • Err(CausalStateError) if an error occurs during evaluation
Source

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 succeeds
  • Err(CsmError) if an error occurs during evaluation
Source§

impl<I, O, C> CausalState<I, O, C>
where I: Default, O: Default + Debug, C: Clone,

Source

pub fn id(&self) -> usize

Source

pub fn version(&self) -> usize

Source

pub fn data(&self) -> &PropagatingEffect<I>

Source

pub fn causaloid(&self) -> &Causaloid<I, O, (), C>

Source

pub fn context(&self) -> &C

Source

pub fn uncertain_parameter(&self) -> &Option<UncertainParameter>

Source§

impl<I, O, C> CausalState<I, O, C>
where I: Default, O: Default + Debug, C: Clone,

Source

pub fn new( id: usize, version: usize, data: PropagatingEffect<I>, causaloid: Causaloid<I, O, (), C>, uncertain_parameter: Option<UncertainParameter>, ) -> Self

Trait Implementations§

Source§

impl<I, O, C> Clone for CausalState<I, O, C>
where I: Default + Clone, O: Default + Debug + Clone, C: Clone + Clone,

Source§

fn clone(&self) -> CausalState<I, O, C>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<I, O, C> Debug for CausalState<I, O, C>
where I: Default + Debug, O: Default + Debug + Debug, C: Clone + Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<I, O, C> Display for CausalState<I, O, C>
where I: Debug + Default, O: Default + Debug, C: Clone,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<I, O, C> Freeze for CausalState<I, O, C>
where I: Freeze, C: Freeze,

§

impl<I, O, C> RefUnwindSafe for CausalState<I, O, C>

§

impl<I, O, C> Send for CausalState<I, O, C>
where C: Send + Sync, I: Send + Sync, O: Send + Sync,

§

impl<I, O, C> Sync for CausalState<I, O, C>
where C: Sync + Send, I: Sync + Send, O: Sync + Send,

§

impl<I, O, C> Unpin for CausalState<I, O, C>
where C: Unpin, I: Unpin, O: Unpin,

§

impl<I, O, C> UnwindSafe for CausalState<I, O, C>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<T> Satisfies<NoConstraint> for T