Skip to main content

swf_core/models/task/
switch_task.rs

1use serde::{Deserialize, Serialize};
2
3use super::{Map, TaskDefinitionFields};
4
5/// Represents the definition of a task that evaluates conditions and executes specific branches based on the result
6#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
7pub struct SwitchTaskDefinition {
8    /// Gets/sets the definition of the switch to use
9    #[serde(rename = "switch")]
10    pub switch: Map<String, SwitchCaseDefinition>,
11
12    /// Gets/sets the task's common fields
13    #[serde(flatten)]
14    pub common: TaskDefinitionFields,
15}
16
17/// Represents the definition of a case within a switch task, defining a condition and corresponding tasks to execute if the condition is met
18#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
19pub struct SwitchCaseDefinition {
20    /// Gets/sets the condition that determines whether or not the case should be executed in a switch task
21    #[serde(rename = "when", skip_serializing_if = "Option::is_none")]
22    pub when: Option<String>,
23
24    /// Gets/sets the transition to perform when the case matches
25    #[serde(rename = "then", skip_serializing_if = "Option::is_none")]
26    pub then: Option<String>,
27}