[−][src]Trait flow_impl::Implementation
An implementation runs with an array of inputs and returns a value (or null) and a bool indicating if it should be ran again.
Any 'implementation' of a function must implement this trait
Examples
Here is an example implementation of this trait:
extern crate core; extern crate flow_impl; #[macro_use] extern crate serde_json; use flow_impl::{Implementation, RUN_AGAIN, RunAgain}; use serde_json::Value; pub struct Compare; /* A compare operator that takes two numbers and outputs the comparisons between them */ impl Implementation for Compare { fn run(&self, mut inputs: Vec<Vec<Value>>) -> (Option<Value>, RunAgain) { let left = inputs[0].remove(0).as_i64().unwrap(); let right = inputs[1].remove(0).as_i64().unwrap(); let output = json!({ "equal" : left == right, "lt" : left < right, "gt" : left > right, "lte" : left <= right, "gte" : left >= right }); (None, RUN_AGAIN) } }
Required methods
fn run(&self, inputs: Vec<Vec<Value>>) -> (Option<Value>, RunAgain)
The run
method is used to execute the implementation