Hi, i have a game.wasm component.
If i do wasm-tools component wit game.wasm i get
package root:component;
world root {
export teleyos:connect4/types@0.0.1;
}
package teleyos:connect4@0.0.1 {
interface types {
enum error-code {
col-not-empty,
out-of-bound,
}
type error = tuple<error-code, string>;
type play-result = result<u8, error>;
enum player {
first,
second,
}
type grid = list<option<player>>;
type winner = player;
resource state {
constructor();
play: func(index: s8) -> play-result;
check-finished: func() -> tuple<bool, option<winner>>;
}
}
}
I want the name or path that i need to give to give to get_func in order to get the check_finished Func.
I tried a lot of possibilities but i struggle to find which path to give because it's in root > teleyos:connect4@0.0.1 > types > state > check-finished and i don't know how to articulate that.
I have this for now :
require 'wasmtime'
engine = Wasmtime::Engine.new
component = Wasmtime::Component::Component.from_file(engine, "./game.wasm")
store = Wasmtime::Store.new(engine, {})
linker = Wasmtime::Component::Linker.new(engine)
instance = linker.instantiate(store, component)
check_finished_func = instance.get_func(["root", "teleyos:connect4@0.0.1","types","state","check-finished"])
if (check_finished_func == nil) then
puts "didn't find function"
puts check_finished_func
exit
end
Thanks a lot for your time and your pieces of advice (trying to not use ai at all for this project)
Update, fixed with this code.
Last updated: Jul 29 2026 at 05:03 UTC