generate!() { /* proc-macro */ }Expand description
Used to generate bindings for a WebAssembly component.
By default, all world exports are expected to be implemented
on a type named Component where the bindings! macro
is invoked.
Additionally, all resource exports are expected to be
implemented on a type named <ResourceName>.
For example, a resource named file would be implemented
on a type named File in the same scope as the generate!
macro invocation.
§Settings
Use the package.metadata.component.bindings section in
Cargo.toml to configure bindings generation.
The available settings are:
implementor: The name of the type to implement world exports on.resources: A map of resource names to resource implementor types.ownership: The ownership model to use for resources.derives: Additional derive macro attributes to add to generated types.
§Examples
Specifying a custom implementor type named MyComponent:
[package.metadata.component.bindings]
implementor = "MyComponent"Specifying a custom resource implementor type named MyResource:
[package.metadata.component.bindings.resources]
"my:package/iface/res" = "MyResource"Specifying the borrowing-duplicate-if-necessary ownership model:
[package.metadata.component.bindings]
ownership = "borrowing-duplicate-if-necessary"