Skip to main content

EngineBuilder

Struct EngineBuilder 

Source
pub struct EngineBuilder { /* private fields */ }
Expand description

Builds an Engine from definitions: functions registered on a Registry, the workflows, and the config. build fails if any workflow is rejected, with every rejected definition’s issues.

A host that quarantines, and runs the workflows that compile, uses a Compiler instead.

use dataflow_rs::Engine;
use dataflow_rs::program::IssueCode;
use serde_json::json;

let issues = Engine::builder()
    .workflow_json(&json!({"id": "w", "tasks": [
        {"id": "t", "function": {"name": "fetch"}}
    ]}))
    .build()
    .unwrap_err();
assert_eq!(issues[0].code, IssueCode::UnknownFunction);

Implementations§

Source§

impl EngineBuilder

Source

pub fn registry(self, registry: Registry) -> Self

Replaces the registry, and every function registered so far with it.

Source

pub fn register<F: Function>(self, name: &str, f: F) -> Self

Registers f under name on the registry, as Registry::register, whose panics it shares.

Source

pub fn layer<L: CallLayer>(self, l: L) -> Self

Adds a layer around every host call on the registry, as Registry::layer: the first added is the outermost.

Source

pub fn options(self, options: CompileOptions) -> Self

Sets the options the workflows compile with.

Source

pub fn config(self, config: EngineConfig) -> Self

Sets the engine’s config.

Source

pub fn workflow(self, def: WorkflowDef) -> Self

Adds a parsed definition.

Source

pub fn workflow_json(self, raw: &Value) -> Self

Adds a definition to parse with ParseOptions::default, the compat reader on. One parse refuses makes build fail with its parse issues, and one it reads but the compile rejects with its parse issues, then its compile issues.

Source

pub fn workflow_json_owned(self, raw: Value) -> Self

Adds an owned definition, avoiding the compatibility reader’s copy. Otherwise identical to Self::workflow_json.

Source

pub fn build(self) -> Result<Engine, Vec<Issue>>

Compiles every definition and links them into the engine’s program.

§Errors

Every issue of every definition that parse or compile_one rejected, in input order, a rejected definition’s parse issues before its compile issues. On success the other issues are dropped: a host that wants them calls Compiler::check.

Trait Implementations§

Source§

impl Debug for EngineBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

The registry, the options, the config and how many definitions it holds.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.