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: CausalEffectLogImplementations§
Source§impl PropagatingEffect
impl PropagatingEffect
Sourcepub fn from_error(err: CausalityError) -> Self
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- TheCausalityErrorto 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());Sourcepub fn none() -> Self
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());Sourcepub fn from_effect_value(effect_value: EffectValue) -> Self
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- TheEffectValueto 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)));Sourcepub fn from_effect_value_with_log(
value: EffectValue,
logs: CausalEffectLog,
) -> Self
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- TheEffectValueto wrap.logs- TheCausalEffectLogcontaining 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());Sourcepub fn from_boolean(boolean: bool) -> Self
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)));Sourcepub fn from_numerical(numerical: NumericalValue) -> Self
pub fn from_numerical(numerical: NumericalValue) -> Self
Creates a new PropagatingEffect of the Numerical variant.
§Arguments
numerical- ANumericalValuerepresenting 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)));Sourcepub fn from_numeric(numeric: NumericValue) -> Self
pub fn from_numeric(numeric: NumericValue) -> Self
Creates a new PropagatingEffect of the Number variant from a NumericValue.
§Arguments
numeric- ANumericValuerepresenting 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))));Sourcepub fn from_probabilistic(numerical: NumericalValue) -> Self
pub fn from_probabilistic(numerical: NumericalValue) -> Self
Creates a new PropagatingEffect of the Probabilistic variant.
§Arguments
numerical- ANumericalValuerepresenting 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)));Sourcepub fn from_tensor(tensor: CausalTensor<f64>) -> Self
pub fn from_tensor(tensor: CausalTensor<f64>) -> Self
Creates a new PropagatingEffect of the Tensor variant.
§Arguments
tensor- ACausalTensor<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(())
}Sourcepub fn from_complex(complex: Complex<f64>) -> Self
pub fn from_complex(complex: Complex<f64>) -> Self
Creates a new PropagatingEffect of the Complex variant.
§Arguments
complex- AComplex<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(_)));Sourcepub fn from_complex_tensor(complex_tensor: ComplexTensor) -> Self
pub fn from_complex_tensor(complex_tensor: ComplexTensor) -> Self
Creates a new PropagatingEffect of the ComplexTensor variant.
§Arguments
complex_tensor- AComplexTensorrepresenting 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(())
}Sourcepub fn from_quaternion(quaternion: Quaternion<f64>) -> Self
pub fn from_quaternion(quaternion: Quaternion<f64>) -> Self
Creates a new PropagatingEffect of the Quaternion variant.
§Arguments
quaternion- AQuaternion<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(_)));Sourcepub fn from_quaternion_tensor(
quaternion_tensor: CausalTensor<Quaternion<f64>>,
) -> Self
pub fn from_quaternion_tensor( quaternion_tensor: CausalTensor<Quaternion<f64>>, ) -> Self
Creates a new PropagatingEffect of the QuaternionTensor variant.
§Arguments
quaternion_tensor- ACausalTensor<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(())
}Sourcepub fn from_uncertain_bool(uncertain: UncertainBool) -> Self
pub fn from_uncertain_bool(uncertain: UncertainBool) -> Self
Creates a new PropagatingEffect of the UncertainBool variant.
§Arguments
uncertain- AnUncertainBoolvalue 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(_)));Sourcepub fn from_uncertain_float(uncertain: UncertainF64) -> Self
pub fn from_uncertain_float(uncertain: UncertainF64) -> Self
Creates a new PropagatingEffect of the UncertainFloat variant.
§Arguments
uncertain- AnUncertainF64value 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(_)));Sourcepub fn from_maybe_uncertain_bool(
maybe_uncertain_bool: MaybeUncertainBool,
) -> Self
pub fn from_maybe_uncertain_bool( maybe_uncertain_bool: MaybeUncertainBool, ) -> Self
Creates a new PropagatingEffect of the MaybeUncertainBool variant.
§Arguments
maybe_uncertain- AMaybeUncertainBoolvalue 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(_)));Sourcepub fn from_maybe_uncertain_float(
maybe_uncertain_float: MaybeUncertainF64,
) -> Self
pub fn from_maybe_uncertain_float( maybe_uncertain_float: MaybeUncertainF64, ) -> Self
Creates a new PropagatingEffect of the MaybeUncertainFloat variant.
§Arguments
maybe_uncertain- AMaybeUncertainF64value 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(_)));Sourcepub fn from_contextual_link(
context_id: ContextoidId,
contextoid_id: ContextoidId,
) -> Self
pub fn from_contextual_link( context_id: ContextoidId, contextoid_id: ContextoidId, ) -> Self
Creates a new PropagatingEffect of the ContextualLink variant.
§Arguments
context_id- TheContextIdof the context.contextoid_id- TheContextoidIdof 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(_,_)));Sourcepub fn from_map(
map: HashMap<IdentificationValue, Box<PropagatingEffect>>,
) -> Self
pub fn from_map( map: HashMap<IdentificationValue, Box<PropagatingEffect>>, ) -> Self
Sourcepub fn from_relay_to(id: usize, effect: Box<PropagatingEffect>) -> Self
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- Theusizeindex of the target causaloid.effect- ABox<PropagatingEffect>representing the effect to be passed as input to the target causaloid.
§Returns
A PropagatingEffect::RelayTo instance.
Source§impl PropagatingEffect
impl PropagatingEffect
Sourcepub fn intervene(self, new_value: EffectValue) -> Self
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 newEffectValueto 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.