Stream: wasmtime

Topic: dynamic wit


view this post on Zulip Ryan Levick (rylev) (Sep 08 2023 at 14:13):

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.

view this post on Zulip Ryan Levick (rylev) (Sep 08 2023 at 14:13):

For now, I'm doing lining up the types myself - would be nice to not have to do that.

view this post on Zulip Lann Martin (Sep 08 2023 at 14:19):

I have looked before and I'm pretty confident there is not, at least in wasm-tools or wasmtime.

view this post on Zulip Ryan Levick (rylev) (Sep 08 2023 at 14:22):

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.

view this post on Zulip Ryan Levick (rylev) (Sep 08 2023 at 14:29):

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

view this post on Zulip Ryan Levick (rylev) (Sep 08 2023 at 14:30):

Ah actually just realizing now that the results don't need to be of the same type..

view this post on Zulip Lann Martin (Sep 08 2023 at 14:37):

Whats the default value of a resource handle? :thinking:

view this post on Zulip Ryan Levick (rylev) (Sep 08 2023 at 14:41):

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