pub struct EngineBuilder { /* private fields */ }Expand description
Builder for Engine. The recommended construction path — chain
register("name", handler) and with_workflow(workflow) calls, then
build() to produce a Result<Engine>. Empty registration is fine; an
engine with no custom handlers still resolves the built-in functions.
register takes any AsyncFunctionHandler and boxes it internally; the
Box<dyn DynAsyncFunctionHandler + Send + Sync> plumbing stays out of
user code.
use dataflow_rs::{Engine, Workflow};
let engine = Engine::builder()
.with_workflow(workflow)
// .register("my_handler", MyHandler)
.build()
.unwrap();Implementations§
Source§impl EngineBuilder
impl EngineBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty builder. Equivalent to EngineBuilder::default.
Sourcepub fn register<F>(self, name: impl Into<String>, handler: F) -> Selfwhere
F: AsyncFunctionHandler,
pub fn register<F>(self, name: impl Into<String>, handler: F) -> Selfwhere
F: AsyncFunctionHandler,
Register a custom async handler under name. Accepts any
AsyncFunctionHandler; boxing happens internally via the engine’s
blanket impl.
Sourcepub fn register_boxed(
self,
name: impl Into<String>,
handler: BoxedFunctionHandler,
) -> Self
pub fn register_boxed( self, name: impl Into<String>, handler: BoxedFunctionHandler, ) -> Self
Register a pre-boxed handler. Useful when handlers are constructed dynamically (e.g. plugin registries) and the concrete type isn’t known at the call site.
Sourcepub fn with_workflow(self, workflow: Workflow) -> Self
pub fn with_workflow(self, workflow: Workflow) -> Self
Add a single workflow. Subsequent calls append.
Sourcepub fn with_workflows<I>(self, workflows: I) -> Selfwhere
I: IntoIterator<Item = Workflow>,
pub fn with_workflows<I>(self, workflows: I) -> Selfwhere
I: IntoIterator<Item = Workflow>,
Append every workflow in workflows. Accepts anything iterable —
Vec<Workflow>, an array, an iterator. Existing workflows on the
builder are kept; subsequent registers/workflows still chain.