Hi, I have been working with WASM in Rust for some time now and came across a usecase, which I can't find information about it. In a nutshell, I have a Rust binary, which calls a WASM components through their exports. The components are like services, which all have the same WIT interface but with own implementations. The issue is that when changes are made to the WIT file, each component has to get the new file, get their bindings regenerated and reimplemented. It is a tedious and error-prone process considering that somebody else will be developing the components and different versions of wit-bindgen might produce different bindings. My question is: is it possible to abstract the generated bindings into a rust lib crate which can be depended on by each component? Instead of each component crate to depend on a local bindings.rs it will depend on a pub mod bindings from a different crate.
https://github.com/bytecodealliance/wasmtime/blob/main/crates/wasi-http/src/bindings.rs
as an example, wasmtime-wasi-http provides the guest bindings for the same reason, to make it possible to keep the rust api stable while the wit may change
note that your users would still have to keep that crate updated and recompile on wit changes unless you start versioning your wit (whhich is what wasi-http does)
Thank you Ramone, I will try their approach. It is interesting how bindings can be created with either wasmtime , cargo component or wit-bindgen
wasmtime-wasi-http is host bindings, not guest bindings. if you want to put your guest bindings all in the same crate, https://github.com/bytecodealliance/wasi-rs is how we do that for wasi
oh sorry I mixed that up, thanks for clarifying
Last updated: Dec 06 2025 at 05:03 UTC