Hello all, I'm considering using WIT Bindgen's WIT format as an interface description language for a runtime I'm building. I think the only thing I need is the parser, at https://github.com/bytecodealliance/wit-bindgen/tree/main/crates/parser.
This runtime is a lot like COM, we've got a bunch of instantiated WASM modules which collaborate via handles to interfaces that they implement.
For example, suppose we have the following WASM module (somewhat simplified):
server.wasm
imports:
fn import(path: string, interface_description: string) -> u32? /* handle or null */;
fn ihttp_handler.service_web_request(handle: u32, request: string) -> string /* response */
Upon initialization, an instance of server.wasm can scan the namespace and import a handle from another wasm module that implements the
ihttp_handler interface. The call to do that would look something like:
let handler: IHttpHandler = import("/handlers/echo_handler", "... WIT interface definition of ihttp_handler ...")?;
/* there is some syntax sugar here, the only thing import actually returns is an integer handle, but this can be exposed in rust
as a trait object */
let response = handler.service_web_request("... HTTP request ");
// do something with the response
I think it's sufficient for me to use the parser, all my runtime really cares about is that the IMPORTs exposed on the consuming module line up with the EXPORTs on the module which exposes the interface, both of which are using fully qualified names like ihttp_handler.service_web_request.
Some functions, like import above, would be availalbe to all modules from the runtime itself.
What thoughts do you guys have of me using the parser crate like that?
Thanks!
We are all focused on building up the component model. If you're doing something else, that's fine, however I don't expect we'll be able to make changes to accommodate it.
That's fine, I wouldn't expect any accommodations. Is WIT itself deprecated? If so, what's the component-model equivalent?
Thanks
Wit is the component model's IDL. It's not deprecated; it's the main show :-).
Last updated: Dec 23 2024 at 12:05 UTC