Stream: wasmtime

Topic: ✔ Running WASM command from the Rust API of wasmtime


view this post on Zulip Raimundo Saona (Nov 18 2024 at 15:13):

[Question] How to do the equivalent of the wasmtime cli wasmtime run <name>.wasm from the API?

Context

I am using the component model to design a plugin system.
As I understand it, the way to go is that each plugin implements the published WIT, and after compiling a component, the .wasm is transformed to a command wasm by composing it. Then, each plugin will be basically a CLI.
I am trying to run these CLIs from the wasmtime API in my app (instead of asking the user to install the wasmtime cli and run it as a command).

Maybe, I am doing something wrong and I do not need the roundtrip of transforming a wasm component to a wasm command component to run it. If so, then is there a working example I can use as reference?

view this post on Zulip Lann Martin (Nov 18 2024 at 15:29):

That's a hard question to answer succinctly; wasmtime run does a lot of things, many of which you probably don't care about. You can see a basic example of running a component with a custom interface here (see the parent dir's README for build instructions).

A fast and secure runtime for WebAssembly. Contribute to bytecodealliance/wasmtime development by creating an account on GitHub.

view this post on Zulip Raimundo Saona (Nov 18 2024 at 15:44):

Thank you for the example!
I agree that it would be an overkill, and I do not need to do everything that run does.

For future reference, I found this talk particularly useful
The code implements the same that you linked, possibly in a way where the decoupling of plugins and host is clearer.

Samples for demonstrating WebAssembly Component Model at Wasm I/O 2024 - ThorstenHans/wasmio-2024-demos

view this post on Zulip Notification Bot (Nov 18 2024 at 15:45):

Raimundo Saona has marked this topic as resolved.


Last updated: Dec 23 2024 at 13:07 UTC