It is possible to use the wit component model with the component-model
feature.
- Install Rust
- Add WASM target with
rustup target add wasm32-unknown-unknown
- Install
wasm-component
withcargo install --git https://github.com/bytecodealliance/cargo-component --locked cargo-component --rev e24c73 e440662bcf265a4c9c8aead1557f3af75e
Note: due to changes in wasi the latest main branch of cargo-component
may not reflect the interface expected by the current version of wasmtime
. As such a specific revision must be targeted.
These steps are the same when running a wit component in wasmtime normally.
Full (minimal viable) example project setup can be found here.
Alternatively, the My first component doc contains detailed step-by-step tutorial on how to compile, load and run a wasm component.
If your world has imports, you can read WIT imports on how to define and use them.
- All primitive types (numbers, char, bool, string) supported
- Exported and imported functions with 0-N arguments and 0-N return values
- Built-in
list
,option
,tuple
andresult
types - Custom
record
,enum
andvariant
types - Imported and exported interfaces
See the wit_components
test folder for supported example usages.