Apologies if this is not the correct place to ask for help, please redirect as needed.
I am playing around with using wasmtime and the component model to do a form of hot reloading for gamedev. I was able to get something working with returning simple records, but I wanted to extend it to use a resource to describe the screen.
You can see the full WIT here but in short:
interface host-api {
resource game-screen { … }
}
interface game-api {
resource game-instance {
constructor();
run-frame: func(mouse: mouse-info, key: keyboard-info, screen: borrow<game-screen>);
}
}
world hotreload-example {
import host-api;
export game-api;
}
The problem I'm running into is that despite import host-api, I am not getting a generated Guest trait for host-api (nor anything in that namespace at all)?
I thought declaring an interface as import would require hosted types for those resources, and that is handled via the guest trait.
Can someone help me figure out what I'm missing?
The relevant code is here
I'm not at a computer so I can't dive in too deep but in the meantime you might find https://docs.rs/wasmtime/latest/wasmtime/component/bindgen_examples/index.html useful
Yeah I saw those samples, I don’t understand why my wit isn’t generating the host trait for my screen resource
Alright, I think maybe I figured out what I was missing.
This is the path to most of the types: exports::example::host::game_api
This is the path to the host: example::host::host_api::Host
I didn't check the other module when I was looking at the generated code.
I'm going to check the module paths more closely and see if I can get it working.
Last updated: Jan 24 2025 at 00:11 UTC