Macro rustyscript::json_args

source ·
macro_rules! json_args {
    ($($arg:expr),+) => { ... };
    () => { ... };
}
Expand description

Map a series of values to a slice of serde_json::Value objects that javascript functions can understand

§Example

use rustyscript::{ Runtime, RuntimeOptions, Module, json_args };
use std::time::Duration;

let module = Module::new("test.js", "
    function load(a, b) {
        console.log(`Hello world: a=${a}, b=${b}`);
    }
    rustyscript.register_entrypoint(load);
");

Runtime::execute_module(
    &module, vec![],
    Default::default(),
    json_args!("test", 5)
)?;