witgen

Rust Rust Version Docs.rs

witgen is a library to help you generate wit definitions in a wit file for WebAssembly. Using this lib in addition to wit-bindgen will help you to import/export types and functions from/to wasm module.

Getting started

toml witgen = "0.2"

bash $ cargo install cargo-witgen

Examples

```rust use witgen::witgen;

[witgen]

struct TestStruct { inner: String, }

[witgen]

enum TestEnum { Unit, Number(u64), String(String), }

[witgen]

fn test(other: Vec, teststruct: TestStruct, otherenum: TestEnum) -> Result<(String, i64), String> { Ok((String::from("test"), 0i64)) } ```

bash $ cargo witgen generate

```wit record TestStruct { inner: string }

variant TestEnum { Unit, Number(u64), String(string), }

test : function(other: list , teststruct: TestStruct, otherenum: TestEnum) -> expected> ```

Roadmap: