swf_builders/services/task/
for_loop.rs1use super::*;
2
3#[derive(Default)]
6pub struct ForTaskDefinitionBuilder {
7 task: ForTaskDefinition,
8}
9
10impl ForTaskDefinitionBuilder {
11 pub fn new() -> Self {
12 Self::default()
13 }
14
15 pub fn each(&mut self, each: &str) -> &mut Self {
17 self.task.for_.each = each.to_string();
18 self
19 }
20
21 pub fn in_(&mut self, in_: &str) -> &mut Self {
23 self.task.for_.in_ = in_.to_string();
24 self
25 }
26
27 pub fn at(&mut self, at: &str) -> &mut Self {
29 self.task.for_.at = Some(at.to_string());
30 self
31 }
32
33 pub fn do_<F>(&mut self, name: &str, setup: F) -> &mut Self
35 where
36 F: FnOnce(&mut TaskDefinitionBuilder),
37 {
38 let mut builder = TaskDefinitionBuilder::new();
39 setup(&mut builder);
40 let task = builder.build();
41 self.task.do_.add(name.to_string(), task);
42 self
43 }
44
45 pub fn while_(&mut self, while_expr: &str) -> &mut Self {
47 self.task.while_ = Some(while_expr.to_string());
48 self
49 }
50}
51
52impl_task_definition_builder_base!(ForTaskDefinitionBuilder, task, TaskDefinition::For);