PropagatingEffect

Type Alias PropagatingEffect 

Source
pub type PropagatingEffect = CausalPropagatingEffect<EffectValue, CausalityError, CausalEffectLog>;

Aliased Type§

pub struct PropagatingEffect {
    pub value: EffectValue,
    pub error: Option<CausalityError>,
    pub logs: CausalEffectLog,
}

Fields§

§value: EffectValue§error: Option<CausalityError>§logs: CausalEffectLog

Implementations§

Source§

impl PropagatingEffect

Source

pub fn from_error(err: CausalityError) -> Self

Creates a new PropagatingEffect that explicitly contains an error.

This constructor is used when an operation results in a CausalityError, and the effect should propagate this error, short-circuiting further computations. The value field is set to EffectValue::None in this case.

§Arguments
  • err - The CausalityError to be encapsulated in the effect.
§Returns

A PropagatingEffect instance with the specified error.

§Examples
use deep_causality::{PropagatingEffect, CausalityError};

let error_effect = PropagatingEffect::from_error(CausalityError::new("Something went wrong".to_string()));
assert!(error_effect.is_err());
Source

pub fn none() -> Self

Creates a new PropagatingEffect with EffectValue::None, no error, and no logs.

This is useful for representing an effect that carries no specific value or outcome, and is not associated with any error or log entries.

§Returns

A PropagatingEffect instance with EffectValue::None.

§Examples
use deep_causality::{PropagatingEffect, EffectValue};

let none_effect = PropagatingEffect::none();
assert!(matches!(none_effect.value, EffectValue::None));
assert!(!none_effect.is_err());
Source

pub fn from_effect_value(effect_value: EffectValue) -> Self

Creates a new PropagatingEffect from a given EffectValue.

This is a generic constructor that wraps any EffectValue into a PropagatingEffect with no error and no logs.

§Arguments
  • effect_value - The EffectValue to wrap.
§Returns

A PropagatingEffect instance containing the given EffectValue.

§Examples
use deep_causality::{PropagatingEffect, EffectValue};

let effect = PropagatingEffect::from_effect_value(EffectValue::Boolean(true));
assert!(matches!(effect.value, EffectValue::Boolean(true)));
Source

pub fn from_effect_value_with_log( value: EffectValue, logs: CausalEffectLog, ) -> Self

Creates a new PropagatingEffect from a given EffectValue and CausalEffectLog.

This constructor allows initializing a PropagatingEffect with both a value and associated logs, but no error.

§Arguments
  • value - The EffectValue to wrap.
  • logs - The CausalEffectLog containing any causal effect logs.
§Returns

A PropagatingEffect instance containing the given EffectValue and logs.

§Examples
use deep_causality::{PropagatingEffect, EffectValue, CausalEffectLog};

let logs = CausalEffectLog::new();
let effect = PropagatingEffect::from_effect_value_with_log(EffectValue::Boolean(true), logs);
assert!(matches!(effect.value, EffectValue::Boolean(true)));
assert!(!effect.is_err());
Source

pub fn from_boolean(boolean: bool) -> Self

Creates a new PropagatingEffect of the Deterministic variant.

§Arguments
  • deterministic - A boolean value representing the deterministic effect.
§Returns

A PropagatingEffect::Deterministic instance.

§Examples
use deep_causality::PropagatingEffect;
use deep_causality::EffectValue;

let effect = PropagatingEffect::from_boolean(true);
assert!(matches!(effect.value, EffectValue::Boolean(true)));
Source

pub fn from_numerical(numerical: NumericalValue) -> Self

Creates a new PropagatingEffect of the Numerical variant.

§Arguments
  • numerical - A NumericalValue representing the numerical effect.
§Returns

A PropagatingEffect::Numerical instance.

§Examples
use deep_causality::{PropagatingEffect, NumericValue, EffectValue};

let effect = PropagatingEffect::from_numerical(123.45);
assert!(matches!(effect.value, EffectValue::Numerical(123.45)));
Source

pub fn from_numeric(numeric: NumericValue) -> Self

Creates a new PropagatingEffect of the Number variant from a NumericValue.

§Arguments
  • numeric - A NumericValue representing the numerical effect.
§Returns

A PropagatingEffect instance containing the NumericValue.

§Examples
use deep_causality::{PropagatingEffect, NumericValue, EffectValue};

let effect = PropagatingEffect::from_numeric(NumericValue::F64(123.45));
assert!(matches!(effect.value, EffectValue::Number(NumericValue::F64(123.45))));
Source

pub fn from_probabilistic(numerical: NumericalValue) -> Self

Creates a new PropagatingEffect of the Probabilistic variant.

§Arguments
  • numerical - A NumericalValue representing the probabilistic effect (e.g., a probability score).
§Returns

A PropagatingEffect::Probabilistic instance.

§Examples
use deep_causality::{PropagatingEffect, EffectValue};

let effect = PropagatingEffect::from_probabilistic(0.75);
assert!(matches!(effect.value, EffectValue::Probabilistic(0.75)));
Source

pub fn from_tensor(tensor: CausalTensor<f64>) -> Self

Creates a new PropagatingEffect of the Tensor variant.

§Arguments
  • tensor - A CausalTensor<f64> representing the tensor effect.
§Returns

A PropagatingEffect::Tensor instance.

§Examples
use deep_causality::{PropagatingEffect, EffectValue};
use deep_causality_tensor::CausalTensor;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let tensor = CausalTensor::new(vec![1.0, 2.0, 3.0], vec![3])?;
    let effect = PropagatingEffect::from_tensor(tensor.clone());
    assert!(matches!(effect.value, EffectValue::Tensor(_)));
    Ok(())
}
Source

pub fn from_complex(complex: Complex<f64>) -> Self

Creates a new PropagatingEffect of the Complex variant.

§Arguments
  • complex - A Complex<f64> representing the complex number effect.
§Returns

A PropagatingEffect instance containing the Complex<f64>.

§Examples
use deep_causality::{PropagatingEffect, EffectValue};
use deep_causality_num::Complex;

let complex = Complex::new(1.0, 2.0);
let effect = PropagatingEffect::from_complex(complex);
assert!(matches!(effect.value, EffectValue::Complex(_)));
Source

pub fn from_complex_tensor(complex_tensor: ComplexTensor) -> Self

Creates a new PropagatingEffect of the ComplexTensor variant.

§Arguments
  • complex_tensor - A ComplexTensor representing the complex tensor effect.
§Returns

A PropagatingEffect::ComplexTensor instance.

§Examples
use deep_causality::{PropagatingEffect, EffectValue};
use deep_causality_num::Complex;
use deep_causality_tensor::CausalTensor;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let complex_tensor = CausalTensor::new(vec![Complex::new(1.0, 2.0)], vec![1])?;
    let effect = PropagatingEffect::from_complex_tensor(complex_tensor.clone());
    assert!(matches!(effect.value, EffectValue::ComplexTensor(_)));
    Ok(())
}
Source

pub fn from_quaternion(quaternion: Quaternion<f64>) -> Self

Creates a new PropagatingEffect of the Quaternion variant.

§Arguments
  • quaternion - A Quaternion<f64> representing the quaternion effect.
§Returns

A PropagatingEffect instance containing the Quaternion<f64>.

§Examples
use deep_causality::{PropagatingEffect, EffectValue};
use deep_causality_num::Quaternion;

let quaternion = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let effect = PropagatingEffect::from_quaternion(quaternion);
assert!(matches!(effect.value, EffectValue::Quaternion(_)));
Source

pub fn from_quaternion_tensor( quaternion_tensor: CausalTensor<Quaternion<f64>>, ) -> Self

Creates a new PropagatingEffect of the QuaternionTensor variant.

§Arguments
  • quaternion_tensor - A CausalTensor<Quaternion<f64>> representing the quaternion tensor effect.
§Returns

A PropagatingEffect instance containing the CausalTensor<Quaternion<f64>>.

§Examples
use deep_causality::{PropagatingEffect, EffectValue};
use deep_causality_num::Quaternion;
use deep_causality_tensor::CausalTensor;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let quaternion_tensor = CausalTensor::new(vec![Quaternion::new(1.0, 2.0, 3.0, 4.0)], vec![1])?;
    let effect = PropagatingEffect::from_quaternion_tensor(quaternion_tensor.clone());
    assert!(matches!(effect.value, EffectValue::QuaternionTensor(_)));
    Ok(())
}
Source

pub fn from_uncertain_bool(uncertain: UncertainBool) -> Self

Creates a new PropagatingEffect of the UncertainBool variant.

§Arguments
  • uncertain - An UncertainBool value representing the uncertain boolean effect.
§Returns

A PropagatingEffect::UncertainBool instance.

§Examples
use deep_causality::{PropagatingEffect, EffectValue};
use deep_causality_uncertain::UncertainBool;

let uncertain_bool = UncertainBool::point(true);
let effect = PropagatingEffect::from_uncertain_bool(uncertain_bool.clone());
assert!(matches!(effect.value, EffectValue::UncertainBool(_)));
Source

pub fn from_uncertain_float(uncertain: UncertainF64) -> Self

Creates a new PropagatingEffect of the UncertainFloat variant.

§Arguments
  • uncertain - An UncertainF64 value representing the uncertain float effect.
§Returns

A PropagatingEffect::UncertainFloat instance.

§Examples
use deep_causality::{PropagatingEffect, EffectValue};
use deep_causality_uncertain::UncertainF64;

let uncertain_float = UncertainF64::point(1.0);
let effect = PropagatingEffect::from_uncertain_float(uncertain_float.clone());
assert!(matches!(effect.value, EffectValue::UncertainFloat(_)));
Source

pub fn from_maybe_uncertain_bool( maybe_uncertain_bool: MaybeUncertainBool, ) -> Self

Creates a new PropagatingEffect of the MaybeUncertainBool variant.

§Arguments
  • maybe_uncertain - A MaybeUncertainBool value representing the possibly uncertain boolean effect.
§Returns

A PropagatingEffect::MaybeUncertainBool instance.

§Examples
use deep_causality::{PropagatingEffect, EffectValue};
use deep_causality_uncertain::MaybeUncertainBool;

let maybe_uncertain_bool = MaybeUncertainBool::from_value(true);
let effect = PropagatingEffect::from_maybe_uncertain_bool(maybe_uncertain_bool.clone());
assert!(matches!(effect.value, EffectValue::MaybeUncertainBool(_)));
Source

pub fn from_maybe_uncertain_float( maybe_uncertain_float: MaybeUncertainF64, ) -> Self

Creates a new PropagatingEffect of the MaybeUncertainFloat variant.

§Arguments
  • maybe_uncertain - A MaybeUncertainF64 value representing the possibly uncertain float effect.
§Returns

A PropagatingEffect::MaybeUncertainFloat instance.

§Examples
use deep_causality::{PropagatingEffect, EffectValue};
use deep_causality_uncertain::MaybeUncertainF64;

let maybe_uncertain_float = MaybeUncertainF64::from_value(1.0);
let effect = PropagatingEffect::from_maybe_uncertain_float(maybe_uncertain_float.clone());
assert!(matches!(effect.value, EffectValue::MaybeUncertainFloat(_)));

Creates a new PropagatingEffect of the ContextualLink variant.

§Arguments
  • context_id - The ContextId of the context.
  • contextoid_id - The ContextoidId of the linked contextoid.
§Returns

A PropagatingEffect::ContextualLink instance.

§Examples
use deep_causality::{PropagatingEffect, EffectValue};

let effect = PropagatingEffect::from_contextual_link(23, 42);
assert!(matches!(effect.value, EffectValue::ContextualLink(_,_)));
Source

pub fn from_map( map: HashMap<IdentificationValue, Box<PropagatingEffect>>, ) -> Self

Creates a new PropagatingEffect of the Map variant from an existing HashMap.

§Arguments
  • map - A HashMap containing IdentificationValue keys and boxed PropagatingEffect values.
§Returns

A PropagatingEffect::Map instance initialized with the given map.

Source

pub fn from_relay_to(id: usize, effect: Box<PropagatingEffect>) -> Self

Creates a new PropagatingEffect of the RelayTo variant.

This variant is used to dispatch a command that directs the reasoning engine to dynamically jump to a specific causaloid within the graph, passing an effect as input.

§Arguments
  • id - The usize index of the target causaloid.
  • effect - A Box<PropagatingEffect> representing the effect to be passed as input to the target causaloid.
§Returns

A PropagatingEffect::RelayTo instance.

Source§

impl PropagatingEffect

Source

pub fn intervene(self, new_value: EffectValue) -> Self

Enables a fluent, chainable intervention in a monadic causal chain.

This method takes ownership of the current effect and a new value, creating a counterfactual by replacing the effect’s value while preserving its context (errors and logs).

§Arguments
  • new_value: The new EffectValue to force into the causal chain.
§Returns

A new PropagatingEffect with the value replaced, ready for the next step in the chain.

§Log Provenance

This method guarantees that the intervention is logged. It calls the underlying CausalMonad::intervene implementation, which is responsible for adding a specific log entry for the intervention before passing the effect along.

Trait Implementations§

Source§

impl Display for PropagatingEffect

Source§

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

Formats the value using the given formatter. Read more