https://github.com/jcbhmr/hello-world-rust-wasm-component-lib
🟪 Rust library compiled to WASM and distributed as a WASM component
https://github.com/jcbhmr/hello-world-rust-wasm-component-lib
component-model rust wasm wasm-component webassembly
Last synced: about 2 months ago
JSON representation
🟪 Rust library compiled to WASM and distributed as a WASM component
- Host: GitHub
- URL: https://github.com/jcbhmr/hello-world-rust-wasm-component-lib
- Owner: jcbhmr
- License: 0bsd
- Created: 2023-12-21T00:06:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-16T02:14:21.000Z (over 1 year ago)
- Last Synced: 2025-02-07T17:15:36.618Z (3 months ago)
- Topics: component-model, rust, wasm, wasm-component, webassembly
- Language: Rust
- Homepage:
- Size: 154 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# "Hello world!" Rust WebAssembly component library
🟪 Rust library compiled to WASM and distributed as a [WASM component]
Download WASM
| View WIT
| JavaScript bindings🦀 Written in Rust \
🟪 Modern WebAssembly Component example \
🌎 Runs on any [WebAssembly Component Runtime] \
📥 Imports some host functions \
📤 Exports some functions \
👩⚖️ [0BSD licensed](./LICENSE) template## Usage

To get started just [download the latest WASM artifact] and use it in your
favorite [WebAssembly Component Runtime]! Make sure you provide any required
imports! 😉## Development

```sh
./just build
```ℹ You'll need [`wasm-tools`] installed which you can get via
`cargo install wasm-tools`.You can inspect the output component WASM using something like this:
```sh
wasm-tools component wit target/wasm32-wasi/debug/*.wasm
#=> world my-component {
# import print: func(msg: string)
# export run: func()
# }
```The `wasi_snapshot_preview1.reactor.wasm` is the adapter module to shim the
component API over top of the existing WASI API. Keep it updated from
[bytecodealliance/wasmtime releases]. Since this is a library we want the
"reactor" version.🚚 To create a new release, don't use the GitHub UI directly; use the [draft
release] GitHub Actions workflow to create the initial draft release with the
compiled WASM artifact. Then you can edit that release and publish it as normal.
Make sure the `version` fields are correct before drafting the release; it's
used to choose the `v${version}` tag name for the release and in publishing.
Also try not to change the artifacts attached to the draft release; they are
generated by GitHub Actions.[webassembly component runtime]: https://github.com/bytecodealliance/wit-bindgen#host-runtimes-for-components
[wasm component]: https://github.com/WebAssembly/component-model
[`wasm-tools`]: https://github.com/bytecodealliance/wasm-tools
[bytecodealliance/wasmtime releases]: https://github.com/bytecodealliance/wasmtime/releases
[draft release]: https://github.com/jcbhmr/hello-world-wasm-component/actions/workflows/draft-release.yml
[download the latest WASM artifact]: https://github.com/jcbhmr/hello-world-rust-wasm-component-lib/releases/latest/download/hello_world_rust_wasm_component_lib.wasm