Wasmer-Runtime
Wasmer-runtime is a library that makes embedding WebAssembly in your application easy, efficient, and safe.
How to use Wasmer-Runtime
The easiest way is to use the instantiate
function to create an Instance
.
Then you can use call
or func
and then call
to call an exported function safely.
Here's an example:
Given this WebAssembly:
(module
(type $t0 (func (param i32) (result i32)))
(func $add_one (export "add_one") (type $t0) (param $p0 i32) (result i32)
get_local $p0
i32.const 1
i32.add))
compiled into wasm bytecode, we can call the exported "add_one" function:
static WASM: &'static = &;
use ;
Additional Notes:
The wasmer-runtime
is build to support compiler multiple backends.
Currently, we support the Cranelift compiler with the wasmer-clif-backend
crate.
You can specify the compiler you wish to use with the compile_with
function.