Function wilton_rusty::runscript[][src]

pub fn runscript(call_desc: &Value) -> Result<String, String>

Call JavaScript function

Allows to call a specified JavaScript function passing arguments as a list of JSON values and receiving result as a String.

Arguments (JSON call descriptor fields)

  • module - name of the RequireJS module
  • func - name of the function field in the module object (optional: not needed if module itself is a function)
  • args - function arguments (optional)

Example

 // create call descriptor
let call_desc = json!({
    "module": "lodash/string",
    "func": "capitalize",
    "args": [msg]
});

 // perform the call and check the results
match wilton_rusty::runscript(&call_desc) {
    Ok(res) => res,
    Err(e) => panic!(e)
}
()