Stream: wit-bindgen

Topic: resource conversion


view this post on Zulip Ludea (Apr 21 2026 at 07:45):

Hi, I don't see much examples of resource with rust.
I get a complex rust struct which is used as func arg.
Instead of rewriting / adapting this struct into wit file, I use a resource instead.
But how to convert the resource as original struct? I need to use the original struct to call a fn

fn myfn(myresource: my-resource) {
    mycrate::func(myoriginalstruct_from resource) ;
}

view this post on Zulip Alex Crichton (Apr 21 2026 at 14:22):

this is an example of the bindings for exported resources, and you'd call the methods there with the right T that you're using

view this post on Zulip Victor Adossi (Apr 21 2026 at 15:22):

Another resource is the section in the Component Model Book about resources in Rust:

https://component-model.bytecodealliance.org/language-support/using-wit-resources/rust.html

(If you find something wrong/unintuitive, please let us know and we'll update the docs there)

view this post on Zulip Ludea (Apr 21 2026 at 15:40):

Thanks for the 2 links but I still don't know what I have to do.
I guess I have to do a From but not sure


Last updated: May 03 2026 at 22:13 UTC