pub struct WasmEngine { /* private fields */ }Expand description
A WebAssembly-compatible workflow engine.
Wraps the dataflow-rs Engine to provide async message processing that returns JavaScript Promises.
Implementations§
Source§impl WasmEngine
impl WasmEngine
Sourcepub fn new(workflows_json: &str) -> Result<WasmEngine, String>
pub fn new(workflows_json: &str) -> Result<WasmEngine, String>
Create a new WasmEngine from a JSON array of workflow definitions.
§Arguments
workflows_json- JSON string containing an array of workflow definitions
§Example
const workflows = JSON.stringify([{
id: "workflow1",
name: "My Workflow",
priority: 1,
tasks: [...]
}]);
const engine = new WasmEngine(workflows);Sourcepub fn process(&self, payload: &str) -> Promise
pub fn process(&self, payload: &str) -> Promise
Process a payload through the engine’s workflows.
This is an async operation that returns a Promise. The payload is stored as a raw string and should be parsed by a parse plugin in the workflow if JSON parsing is needed.
§Arguments
payload- Raw string payload to process (not parsed by the engine)
§Returns
A Promise that resolves to the processed message as a JSON string
§Example
const payload = '{"name": "John", "email": "john@example.com"}';
const result = await engine.process(payload);
const processed = JSON.parse(result);
console.log(processed.context.data);Sourcepub fn process_with_trace(&self, payload: &str) -> Promise
pub fn process_with_trace(&self, payload: &str) -> Promise
Process a payload with step-by-step execution tracing.
This is an async operation that returns a Promise with the execution trace. The trace contains message snapshots after each step, including which workflows/tasks were executed or skipped. The payload is stored as a raw string and should be parsed by a parse plugin.
§Arguments
payload- Raw string payload to process (not parsed by the engine)
§Returns
A Promise that resolves to the execution trace as a JSON string
§Example
const payload = '{"name": "John", "email": "john@example.com"}';
const trace = await engine.process_with_trace(payload);
const traceData = JSON.parse(trace);
console.log(traceData.steps); // Array of execution stepsSourcepub fn workflow_count(&self) -> usize
pub fn workflow_count(&self) -> usize
Get the number of workflows registered in the engine.
Sourcepub fn workflow_ids(&self) -> String
pub fn workflow_ids(&self) -> String
Trait Implementations§
Source§impl From<WasmEngine> for JsValue
impl From<WasmEngine> for JsValue
Source§fn from(value: WasmEngine) -> Self
fn from(value: WasmEngine) -> Self
Source§impl FromWasmAbi for WasmEngine
impl FromWasmAbi for WasmEngine
Source§impl IntoWasmAbi for WasmEngine
impl IntoWasmAbi for WasmEngine
Source§impl LongRefFromWasmAbi for WasmEngine
impl LongRefFromWasmAbi for WasmEngine
Source§impl OptionFromWasmAbi for WasmEngine
impl OptionFromWasmAbi for WasmEngine
Source§impl OptionIntoWasmAbi for WasmEngine
impl OptionIntoWasmAbi for WasmEngine
Source§impl RefFromWasmAbi for WasmEngine
impl RefFromWasmAbi for WasmEngine
Source§type Anchor = RcRef<WasmEngine>
type Anchor = RcRef<WasmEngine>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for WasmEngine
impl RefMutFromWasmAbi for WasmEngine
Source§impl TryFromJsValue for WasmEngine
impl TryFromJsValue for WasmEngine
Source§impl VectorFromWasmAbi for WasmEngine
impl VectorFromWasmAbi for WasmEngine
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[WasmEngine]>
Source§impl VectorIntoWasmAbi for WasmEngine
impl VectorIntoWasmAbi for WasmEngine
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[WasmEngine]>) -> Self::Abi
Source§impl WasmDescribeVector for WasmEngine
impl WasmDescribeVector for WasmEngine
impl SupportsConstructor for WasmEngine
impl SupportsInstanceProperty for WasmEngine
impl SupportsStaticProperty for WasmEngine
Auto Trait Implementations§
impl Freeze for WasmEngine
impl !RefUnwindSafe for WasmEngine
impl Send for WasmEngine
impl Sync for WasmEngine
impl Unpin for WasmEngine
impl !UnwindSafe for WasmEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.