#dispatcher #api #gwasm #runner #dyn #high #split-context

gwasm-dispatcher

High level API for gWasmRunner compatible apps

1 unstable release

0.1.0 Feb 12, 2020

#840 in WebAssembly

GPL-3.0 license

27KB
721 lines

gWASM Runner API for RUST.

Examples

use gwasm_api::{dispatcher, SplitContext};

fn main() {
    dispatcher::run(
        move |_: &mut dyn SplitContext| {
            const NUM_SUBTASKS: usize = 10;
            let arr: Vec<u64> = (1..=100).collect();
            arr.chunks(NUM_SUBTASKS)
                .map(|x| (x.to_vec(),))
                .collect::<Vec<_>>()
        },
        |task: Vec<u64>| (task.into_iter().sum(),),
        |_: &Vec<String>, results: Vec<(_, _)>| {
            let given: u64 = results.iter().map(|(_, (result,))| result).sum();
            let expected: u64 = (1..=100).sum();
            assert_eq!(expected, given, "sums should be equal")
        },
    )
        .unwrap()
}

Dependencies

~0.7–1.5MB
~34K SLoC