Skip to main content

EngineBuilder

Struct EngineBuilder 

Source
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

Source

pub fn new() -> Self

Create an empty builder. Equivalent to EngineBuilder::default.

Source

pub fn register<F>(self, name: impl Into<String>, handler: F) -> Self

Register a custom async handler under name. Accepts any AsyncFunctionHandler; boxing happens internally via the engine’s blanket impl.

Source

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.

Source

pub fn with_workflow(self, workflow: Workflow) -> Self

Add a single workflow. Subsequent calls append.

Source

pub fn with_workflows<I>(self, workflows: I) -> Self
where 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.

Source

pub fn build(self) -> Result<Engine>

Compile the workflows, pre-parse Custom inputs, and produce the engine. Compile errors and missing handler references surface here — the engine never deserializes Custom config on the hot path.

Trait Implementations§

Source§

impl Default for EngineBuilder

Source§

fn default() -> EngineBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.