Skip to main content

swf_core/models/task/
emit_task.rs

1use serde::{Deserialize, Serialize};
2
3use super::TaskDefinitionFields;
4use crate::models::event::EventDefinition;
5
6/// Represents the configuration of a task used to emit an event
7#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
8pub struct EmitTaskDefinition {
9    /// Gets/sets the configuration of an event's emission
10    #[serde(rename = "emit")]
11    pub emit: EventEmissionDefinition,
12
13    /// Gets/sets the task's common fields
14    #[serde(flatten)]
15    pub common: TaskDefinitionFields,
16}
17impl EmitTaskDefinition {
18    /// Initializes a new EmitTaskDefinition
19    pub fn new(emit: EventEmissionDefinition) -> Self {
20        Self {
21            emit,
22            common: TaskDefinitionFields::new(),
23        }
24    }
25}
26
27/// Represents the configuration of an event's emission
28#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
29pub struct EventEmissionDefinition {
30    /// Gets/sets the definition of the event to emit
31    #[serde(rename = "event")]
32    pub event: EventDefinition,
33}
34impl EventEmissionDefinition {
35    pub fn new(event: EventDefinition) -> Self {
36        Self { event }
37    }
38}