Stream: wit-bindgen

Topic: `From` implementation in bindings


view this post on Zulip Daniel Macovei (Mar 16 2023 at 19:09):

https://bytecodealliance.zulipchat.com/#narrow/stream/206238-general/topic/cargo.20component.20param.20vs.20result/near/342360176
I asked a question over in general pertaining to cargo component, and realized later that this is probably the place for it.

view this post on Zulip Daniel Macovei (Mar 16 2023 at 19:11):

Essentially wondering if it makes sense to add a From trait to convert between TypeParam and TypeResult types in bindings that are generated, so that return types of one wit import can be passed to another

view this post on Zulip Daniel Macovei (Mar 16 2023 at 19:12):

Cows were brought up as another solution

view this post on Zulip Lann Martin (Mar 16 2023 at 19:17):

^ In particular, unifying *Param and *Result by using Cows for heap-allocated fields

view this post on Zulip Alex Crichton (Mar 16 2023 at 20:19):

Another option here would be https://github.com/bytecodealliance/wit-bindgen/issues/535, which I think would be reasonable to turn on by default, which is to always generate APIs with owned types and only optionally generate the *Param and *Result structures

G'day again! Under certain scenarios, wit-bindgen (and Wasmtime, which uses similar machinery) will use borrowed types instead of owned types for arrays and strings. This works fine when it&#39...

view this post on Zulip Alex Crichton (Mar 16 2023 at 20:20):

I'm not sure that anyone really wants the *Param and *Result stuff anyway, it's just how I implemented it originally because I assumed we'd want it for performance but in the end it's so confusing I don't think it's worth it

view this post on Zulip Daniel Macovei (Mar 17 2023 at 14:18):

ah yeah, looks like that would take care of it too

view this post on Zulip bachrc (Mar 18 2023 at 16:31):

I permit myself to link the topic where I struggle with the same topic https://bytecodealliance.zulipchat.com/#narrow/stream/327223-wit-bindgen/topic/.5Brust.5D.20param.20and.20result.20structs

view this post on Zulip bachrc (Mar 18 2023 at 16:43):

Actually, it is pretty hard to just give a Vec as a parameter. The Param works for inlining a parameter, but when you need to give a list of objects, and give it as a parameter... this is a lifetimes hell


Last updated: Nov 22 2024 at 16:03 UTC