witgen
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
- Put this dependency in your
Cargo.toml
= "0.3"
- Install
cargo witgenCLI
Examples
- Into your Rust code:
use witgen;
- Then you can launch (at the root of your package):
- It will generate a
witgen.witfile at the root of your package:
record TestStruct {
inner: string
}
variant TestEnum {
Unit,
Number(u64),
String(string),
}
test : function(other: list <u8>, test_struct: TestStruct, other_enum: TestEnum) -> expected<tuple<string, s64>>
Development
It's a very minimal version, it doesn't already support all kinds of types but the main used are supported. I made it to easily generate .wit files for my need. Feel free to create issues or pull-requests if you need something. I will be happy to help you !