ssvm-wasi-helper

Crates.iossvm-wasi-helper
lib.rsssvm-wasi-helper
version0.1.3
sourcesrc
created_at2020-07-31 09:21:22.899637
updated_at2021-05-04 07:55:21.758704
descriptionA rust crate to call the wasm-wasi initialization helper function.
homepagehttps://github.com/second-state/ssvm-wasi-helper/
repositoryhttps://github.com/second-state/ssvm-wasi-helper/
max_upload_size
id271587
size5,229
hydai (hydai)

documentation

README

SSVM wasi helper

Usage

In the Cargo.toml

[dependencies]
ssvm-wasi-helper = "=0.1.3"

To enable the wasi feature

In your wasi functions

use ssvm_wasi_helper::ssvm_wasi_helper::_initialize;
pub fn func1() {
  _initialize();
  // do something which is related to wasi environment variables, arguments, and preopens.
}

To get string data from caller (with SSVM-go support)

use ssvm_wasi_helper::ssvm_wasi_helper::get_string_from_caller;
pub fn func1() {
  let s = get_string_from_caller();
  // do something with the string `s`
}

To get byte array data from caller (with SSVM-go support)

use ssvm_wasi_helper::ssvm_wasi_helper::get_bytes_from_caller;
pub fn func1() {
  let bs = get_bytes_from_caller();
  // do something with the Vec<u8> `bs`
}

To send string data to caller (with SSVM-go support)

use ssvm_wasi_helper::ssvm_wasi_helper::send_string_to_caller;
pub fn func1() {
  let s = "hello";
  send_string_to_caller(s);
}

To get byte array data from caller (with SSVM-go support)

use ssvm_wasi_helper::ssvm_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);
}
Commit count: 7

cargo fmt