Crate wilton_rust [] [src]

Rust modules support for Wilton JavaScript runtime

Usage example:

// configure Cargo to build a shared library
crate-type = ["dylib"]

// in, import serde and wilton_rust
extern crate serde_derive;
extern crate wilton_rust;
// declare input/output structs
struct MyIn { ... }
struct MyOut { ... }
// write a function that does some work
fn hello(obj: MyIn) -> MyOut { ... }
// register that function inside the `wilton_module_init` function,
// that will be called by Wilton during the Rust module load
pub extern "C" fn wilton_module_init() -> *mut std::os::raw::c_char {
   // register a call, error checking omitted
   wilton_rust::register_wiltocall("hello", |obj: MyIn| { hello(obj) });
   // return success status to Wilton

See an example how to load and use Rust library from JavaScript.



Create an error message, that can be passed back to Wilton


Registers a closure, that can be called from JavaScript


Call JavaScript function