Is there a way to go from wit-parser types that you would find in wit_parser::WorldItem
to wasmtime::component::values::Val
types? I'm trying to call into components that I don't know the world definition until runtime.
For now, I'm doing lining up the types myself - would be nice to not have to do that.
I have looked before and I'm pretty confident there is not, at least in wasm-tools or wasmtime.
This would be useful to have, no? Especially with custom types, it's a lot of book keeping to have to chase type ids through to the definition and build up the wasmtime::component::values::Val
from that. If it seems generally useful I can look into separating this out into reusable logic.
I guess it's a bit hard to make generic since you're going from type to value, and it's not really obvious what the values should be in all cases. For my usage right now, I just need a "default" value since these will be written over by result values from the function call
Ah actually just realizing now that the results don't need to be of the same type..
Whats the default value of a resource handle? :thinking:
Yea exactly - there is none - but luckily I was just thinking about things wrong, and I don't actually need defaults. I just need a placeholder val of any kind so I can just use Val::Bool(false)
to all return values
Last updated: Nov 22 2024 at 17:03 UTC