wfe_core/builder/
inline_step.rs1use async_trait::async_trait;
2
3use crate::models::ExecutionResult;
4use crate::traits::step::{StepBody, StepExecutionContext};
5
6type InlineFn = Box<dyn Fn() -> ExecutionResult + Send + Sync>;
7
8pub struct InlineStep {
10 body: InlineFn,
11}
12
13impl InlineStep {
14 pub fn new(f: impl Fn() -> ExecutionResult + Send + Sync + 'static) -> Self {
15 Self { body: Box::new(f) }
16 }
17}
18
19impl Default for InlineStep {
20 fn default() -> Self {
21 Self::new(ExecutionResult::next)
22 }
23}
24
25#[async_trait]
26impl StepBody for InlineStep {
27 async fn run(&mut self, _context: &StepExecutionContext<'_>) -> crate::Result<ExecutionResult> {
28 Ok((self.body)())
29 }
30}