https://github.com/thangchung/wasi-wit-wasm-component-experiment
Very early experiment on WASI, WIT, and Wasm Component Model with Rust and C#
https://github.com/thangchung/wasi-wit-wasm-component-experiment
component-model wasi wasm webassembly wit
Last synced: about 2 months ago
JSON representation
Very early experiment on WASI, WIT, and Wasm Component Model with Rust and C#
- Host: GitHub
- URL: https://github.com/thangchung/wasi-wit-wasm-component-experiment
- Owner: thangchung
- License: mit
- Created: 2023-12-05T16:16:37.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-05T17:00:24.000Z (over 2 years ago)
- Last Synced: 2024-10-11T22:16:24.095Z (over 1 year ago)
- Topics: component-model, wasi, wasm, webassembly, wit
- Language: Rust
- Homepage:
- Size: 39.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Add solution
This repository is for experiment [`wasm-component-sdk`](https://github.com/SteveSandersonMS/wasm-component-sdk).
> Run on Windows 11 only. It couldn't work on Ubuntu or MacOS 😂
## wasm/wasi component with C#
```sh
> dotnet new sln -n calculator
> dotnet sln calculator.sln add MyApp/MyApp.csproj
> dotnet sln calculator.sln add Adder/Adder.csproj
```
```sh
> cd Adder
> dotnet build
```
You should see the wasm/wasi component at `bin\Debug\net8.0\wasi-wasm\native\Adder.component.wasm`
## wasm/wasi component with Spin (Rust)
```sh
> cd rust-host
> spin build
> spin run
> curl http://127.0.0.1:3000/?"x=10&y=40"
```
## wasm-tools (compose and run `Adder` on MyApp - C#)
```sh
> wasm-tools component wit Adder\bin\Debug\net8.0\wasi-wasm\native\Adder.component.wasm
```
```sh
> wasm-tools compose -o composed.wasm MyApp\bin\Debug\net8.0\wasi-wasm\native\MyApp.component.wasm -d Adder\bin\Debug\net8.0\wasi-wasm\native\Adder.component.wasm
> wasmtime --wasm component-model composed.wasm
```
## Refs
- https://devblogs.microsoft.com/dotnet/extending-web-assembly-to-the-cloud/
- https://learn.microsoft.com/en-us/windows/dev-environment/rust/setup