Crates.io | wasmedge-wasi-helper |
lib.rs | wasmedge-wasi-helper |
version | 0.2.0 |
source | src |
created_at | 2021-09-17 03:59:59.506784 |
updated_at | 2021-09-17 03:59:59.506784 |
description | A rust crate to call the wasm-wasi initialization helper function. |
homepage | https://github.com/second-state/wasmedge-wasi-helper/ |
repository | https://github.com/second-state/wasmedge-wasi-helper/ |
max_upload_size | |
id | 452613 |
size | 5,361 |
In the Cargo.toml
[dependencies]
wasmedge-wasi-helper = "=0.2.0"
In your wasi functions
use wasmedge_wasi_helper::wasmedge_wasi_helper::_initialize;
pub fn func1() {
_initialize();
// do something which is related to wasi environment variables, arguments, and preopens.
}
use wasmedge_wasi_helper::wasmedge_wasi_helper::get_string_from_caller;
pub fn func1() {
let s = get_string_from_caller();
// do something with the string `s`
}
use wasmedge_wasi_helper::wasmedge_wasi_helper::get_bytes_from_caller;
pub fn func1() {
let bs = get_bytes_from_caller();
// do something with the Vec<u8> `bs`
}
use wasmedge_wasi_helper::wasmedge_wasi_helper::send_string_to_caller;
pub fn func1() {
let s = "hello";
send_string_to_caller(s);
}
use wasmedge_wasi_helper::wasmedge_wasi_helper::send_bytes_to_caller;
pub fn func1() {
let bs = vec![0u8, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
send_bytes_to_caller(bs);
}