Skip to content

Latest commit

 

History

History
35 lines (22 loc) · 1.63 KB

component_model.md

File metadata and controls

35 lines (22 loc) · 1.63 KB

Component model

It is possible to use the wit component model with the component-model feature.

Pre-requirements

  1. Install Rust
  2. Add WASM target with rustup target add wasm32-unknown-unknown
  3. Install wasm-component with cargo 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.

Project setup

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.

Implemented features

  • 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 and result types
  • Custom record, enum and variant types
  • Imported and exported interfaces

See the wit_components test folder for supported example usages.