1个不稳定版本
0.2.0 | 2021年9月17日 |
---|
#966 in WebAssembly
6KB
56 行
WASMEDGE wasi辅助工具
使用方法
Cargo.toml中
[dependencies]
wasmedge-wasi-helper = "=0.2.0"
启用wasi功能
在你的wasi函数中
use wasmedge_wasi_helper::wasmedge_wasi_helper::_initialize;
pub fn func1() {
_initialize();
// do something which is related to wasi environment variables, arguments, and preopens.
}
从调用者获取字符串数据(支持WASMEDGE-go)
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`
}
从调用者获取字节数组数据(支持WASMEDGE-go)
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`
}
向调用者发送字符串数据(支持WASMEDGE-go)
use wasmedge_wasi_helper::wasmedge_wasi_helper::send_string_to_caller;
pub fn func1() {
let s = "hello";
send_string_to_caller(s);
}
从调用者获取字节数组数据(支持WASMEDGE-go)
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);
}