wasmedge-bindgen-macro

Crates.iowasmedge-bindgen-macro
lib.rswasmedge-bindgen-macro
version0.4.1
sourcesrc
created_at2021-12-21 08:23:52.467464
updated_at2022-11-18 03:35:10.176944
descriptionPass string, vec and primitive types from host to webassembly
homepage
repositoryhttps://github.com/second-state/wasmedge-bindgen
max_upload_size
id501069
size21,863
DarumaDocker!! (DarumaDocker)

documentation

README

About

This crate only export a macro named #[wasmedge_bindgen] that used for retouching exporting functions to make it support more data types.

Data Types

Parameters

You can set the parameters to any one of the following types:

  • Scalar Types: i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, bool, char
  • String
  • Vec: Vec<i8>, Vec<u8>, Vec<i16>, Vec<u16>, Vec<i32>, Vec<u32>, Vec<i64>, Vec<u64>

Return Values

You can set the return values to any one of the following types:

  • Scalar Types: i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, bool, char
  • String
  • Vec: Vec<i8>, Vec<u8>, Vec<i16>, Vec<u16>, Vec<i32>, Vec<u32>, Vec<i64>, Vec<u64>
  • Tuple Type: compounded by any number of the above three types
  • Result: Ok<any one of the above four types>, Err<String>

The only way to tell the host that the error has occurred is to return Err<String> of Result.

Examples

#[wasmedge_bindgen]
pub fn create_line(p1: String, p2: String, desc: String) -> String

#[wasmedge_bindgen]
pub fn lowest_common_multiple(a: i32, b: i32) -> i32

#[wasmedge_bindgen]
pub fn sha3_digest(v: Vec<u8>) -> Vec<u8>

#[wasmedge_bindgen]
pub fn info(v: Vec<u8>) -> Result<(u8, String), String>
Commit count: 40

cargo fmt