wasmer-wasi-near

Crates.iowasmer-wasi-near
lib.rswasmer-wasi-near
version1.0.1
sourcesrc
created_at2021-02-05 00:43:19.335895
updated_at2021-02-05 00:43:19.335895
descriptionWASI implementation library for Wasmer WebAssembly runtime
homepage
repositoryhttps://github.com/wasmerio/wasmer
max_upload_size
id350812
size264,970
Nikolay Igotti (olonho)

documentation

README

wasmer-wasi Build Status Join Wasmer Slack MIT License crates.io

This crate provides the necessary imports to use WASI easily from Wasmer.

Usage

use wasmer::{Store, Module, Instance};
use wasmer_wasi::WasiState;

let store = Store::default();
let module = Module::from_file(&store, "my_wasi_module.wasm")?;

// Create the WasiEnv
let wasi_env = WasiState::new("command name")
    .args(&["world"])
    .env("KEY", "VALUE")
    .finalize()?;

let import_object = wasi_env.import_object(&module)?;
let instance = Instance::new(&module, &import_object)?;

wasi_env.set_memory(instance.exports.get_memory("memory")?.clone());

let start = instance.exports.get_function("_start")?;
start.call(&[])?;

Note: you can find a full working example using WASI here.

Commit count: 17039

cargo fmt