Hi, I'm using the latest main
branch of wit-bindgen
to try the new resource type. I created the wit file:
package foo:bar
world plugin {
record x {
y: u32
}
export foo: func(bar: x)
}
But when I used wit_bindgen::generate!
to generate the bindings, it gave the error:
export parameter required for `world` ...
The error does not happen on 0.9. Is there anything changed in the syntax? (I've checked the component-model proposal but didn't find changes related to this).
the bindgen macro has changed on main, you now have to specify the struct that will impl the trait in the macro call so that more boilerplate can be generated, this is needed for resources
but that message confused me too, "export required" could be more verbose to tell you that the bindgen macro call is missing info, not the wit file
Thanks for the info. So I think all the types exported must have a struct specified in the macro. But how does wit-bindgen
decide which types/resources are exported?
If I have
package foo:bar
interface callback-types {
resource callback {
call: func() -> u32
}
}
world plugin {
export callback-types
}
Then wit-bindgen
generates callback
as a trait which I can implement. But
when I change it to
package foo:bar
interface callback-types {
resource callback {
call: func() -> u32
}
}
world plugin {
use callback-types.{callback}
export callback-types
import register-callback: func(callback: callback)
export run: func()
}
Then wit-bindgen
somehow assumes that callback
is a type import from the host. Is this intended?
Last updated: Nov 22 2024 at 16:03 UTC