Skip to main content

sub_workflow_names

Function sub_workflow_names 

Source
pub fn sub_workflow_names(handlers: &[&dyn WorkflowHandler]) -> Vec<String>
Expand description

Names of the given handlers, for WorkflowHandler::sub_workflows.

Pass the handlers themselves rather than their names: a misspelled handler does not compile, a misspelled string does.

ยงExamples

use ironflow_engine::context::WorkflowContext;
use ironflow_engine::handler::{HandlerFuture, WorkflowHandler, sub_workflow_names};

struct Collect;

impl WorkflowHandler for Collect {
    fn name(&self) -> &str { "collect" }
    fn execute<'a>(&'a self, _ctx: &'a mut WorkflowContext) -> HandlerFuture<'a> {
        Box::pin(async move { Ok(()) })
    }
}

struct Enrich;

impl WorkflowHandler for Enrich {
    fn name(&self) -> &str { "enrich" }
    fn execute<'a>(&'a self, _ctx: &'a mut WorkflowContext) -> HandlerFuture<'a> {
        Box::pin(async move { Ok(()) })
    }
}

assert_eq!(sub_workflow_names(&[&Collect, &Enrich]), vec!["collect", "enrich"]);
assert!(sub_workflow_names(&[]).is_empty());