wasmcloud-provider-wit-bindgen
This crate contains a Rust compile time procedural macro which makes it easy to develop WIT-based wasmcloud capbility provider binaries written in Rust.
Quickstart
It all starts with wasmcloud_provider_wit_bindgen::generate
, for example:
!;
generate
Assuming a struct named KvRedisProvider
exists in your source code and you have a provider-kvredis
world defined in your wit/
folder, the above macro will expand to Trait
s, struct
s, and other required machinery to implement a wasmcloud capability provider.
[!NOTE] For a full example, see the
kv-redis
provider in wasmcloud
By using the generate
macro, you'll be required to write implementation blocks like the following:
Don't worry, types like SetRequest
and GetResponse
above will be provided by the expanded macro code.
Re-exports
Note that wasmcloud-provider-wit-bindgen
re-exports many dependencies in order to ensure that they match and are usable together:
It's recommended to use these dependencies in your code to avoid duplicating dependencies which could lead to all sorts of problems. For example the following use
block:
use ;
Special case: re-using serde
When re-using a re-exported serde
, a known issue exists which requires that you must use the #[serde(crate = "...")]
directive: