THis is an example of a hyperlight-wasm application that runs a wasm component inside a hyperlight-sandbox that implements a calculator (similar to the component model example here).
The calculator itself is comprised of three wasm components:
calculator
- the main component that implements the calculator interface (written in Rust)adder
- a component that implements the addition operation (written in Rust)subtractor
- a component that implements the subtraction operation (written in Javascript)- Additionally there is a
multiply
operator that is implemented as a hyperlight host function.
The example program loads the composed calculator/wasm component into a hyperlight-sandbox along with a wasm runtime and invokes functions as hyperlight-guest calls.
To build and run this example, you need the following tools installed on your system:
- Rust toolchain including
x86_unknown-none
target - Node.js (to build the subtractor wasm component)
- wasm-tools
- wac
- cargo component
- hyperlight-wasm-aot
- cargo install --git https://github.com/hyperlight-dev/hyperlight-wasm hyperlight-wasm-aot
- Just
- Build the guest component
just build-component
- Run the example program
just run-example