wasmer ~memory

A standalone WebAssembly runtime for running WebAssembly outside of the browser


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

wasmer-d

DUB Package wasmer-d CI codecov

D bindings to wasmer, a standalone WebAssembly runtime for running WebAssembly outside of the browser.

Also includes an idiomatic D wrapper of the Wasmer Runtime C API.

Usage

"dependencies": {
    "wasmer": "0.1.0-alpha.2"
}

See the official Wasmer Runtime C API documentation.

Run a WebAssembly Module

Sum function in a WebAssembly text format module:

const string wat_sum_module =
  "(module\n" ~
  "  (type $sum_t (func (param i32 i32) (result i32)))\n" ~
  "  (func $sum_f (type $sum_t) (param $x i32) (param $y i32) (result i32)\n" ~
  "    local.get $x\n" ~
  "    local.get $y\n" ~
  "    i32.add)\n" ~
  "  (export \"sum\" (func $sum_f)))";

auto engine = new Engine();
auto store = new Store(engine);
auto module_ = Module.from(store, wat_sum_module);
auto instance = new Instance(store, module_);
auto sumFunc = Function.from(instance.exports[0]);

assert(engine.valid && store.valid && module_.valid && instance.valid && sumFunc.valid, "Could not instantiate module!");

Value[] results;
assert(sumFunc.call([new Value(3), new Value(4)], results), "Error calling the `sum` function!");
assert(results.length == 1 && results[0].value.of.i32 == 7);

License

MIT Licence

Copyright © 2020 Chance Snow. All rights reserved.

Authors:
  • Chance Snow
Dependencies:
none
System dependencies:
linux: wasmer-1.0.0-rc1
Versions:
0.2.0 2021-Jan-09
0.1.0 2021-Jan-06
0.1.0-alpha.4 2020-Dec-27
0.1.0-alpha.3 2020-Dec-26
0.1.0-alpha.2 2020-Dec-25
Show all 11 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 49 downloads total

Score:
1.2
Short URL:
wasmer.dub.pm