wilton_rust 0.1.0

Rust modules support for Wilton JavaScript runtime
Documentation

Rust modules support for Wilton JavaScript runtime

Usage example:

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

/ in lib.rs, import serde and wilton_rust
[macro_use]
xtern crate serde_derive;
xtern crate wilton_rust;
...
/ declare input/output structs
[derive(Deserialize)]
truct MyIn { ... }
[derive(Serialize)]
truct MyOut { ... }
...
/ write a function that does some work
n hello(obj: MyIn) -> MyOut { ... }
...
/ register that function inside the `wilton_module_init` function,
/ that will be called by Wilton during the Rust module load
[no_mangle]
ub 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
   wilton_rust::create_wilton_error(None)


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