pub struct StateTransition {
pub from_state: String,
pub to_state: String,
pub probability: f64,
pub condition: Option<String>,
pub side_effects: Option<Vec<String>>,
pub condition_expression: Option<String>,
pub condition_ast: Option<Value>,
pub sub_scenario_ref: Option<String>,
}Expand description
State transition definition
Fields§
§from_state: StringSource state
to_state: StringDestination state
probability: f64Probability of this transition occurring (0.0 to 1.0)
condition: Option<String>Optional condition for this transition (legacy string format)
side_effects: Option<Vec<String>>Optional side effects of this transition
condition_expression: Option<String>JavaScript/TypeScript expression for conditional transition
This is the new preferred way to specify conditions. Supports full JavaScript expressions with variable access, comparison, and logical operators.
condition_ast: Option<Value>Parsed condition AST for validation (not serialized, computed on demand)
sub_scenario_ref: Option<String>Reference to a sub-scenario to execute during this transition
If set, the sub-scenario will be executed when this transition is taken.
Implementations§
Source§impl StateTransition
impl StateTransition
Sourcepub fn new(from: impl Into<String>, to: impl Into<String>) -> Self
pub fn new(from: impl Into<String>, to: impl Into<String>) -> Self
Create a new state transition
Sourcepub fn with_probability(self, probability: f64) -> Self
pub fn with_probability(self, probability: f64) -> Self
Set probability
Sourcepub fn with_condition(self, condition: impl Into<String>) -> Self
pub fn with_condition(self, condition: impl Into<String>) -> Self
Set condition
Sourcepub fn with_side_effect(self, effect: impl Into<String>) -> Self
pub fn with_side_effect(self, effect: impl Into<String>) -> Self
Add side effect
Sourcepub fn with_condition_expression(self, expression: impl Into<String>) -> Self
pub fn with_condition_expression(self, expression: impl Into<String>) -> Self
Set condition expression (JavaScript/TypeScript)
Sourcepub fn with_sub_scenario_ref(self, sub_scenario_id: impl Into<String>) -> Self
pub fn with_sub_scenario_ref(self, sub_scenario_id: impl Into<String>) -> Self
Set sub-scenario reference
Trait Implementations§
Source§impl Clone for StateTransition
impl Clone for StateTransition
Source§fn clone(&self) -> StateTransition
fn clone(&self) -> StateTransition
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more