Crates.io | wasmcloud-provider-wit-bindgen-macro |
lib.rs | wasmcloud-provider-wit-bindgen-macro |
version | 0.1.1 |
source | src |
created_at | 2024-03-27 18:30:25.632558 |
updated_at | 2024-03-27 18:30:25.632558 |
description | Internal-use bindgen macro for binary-based wasmCloud capability providers written in Rust |
homepage | |
repository | https://github.com/wasmCloud/wasmCloud |
max_upload_size | |
id | 1188268 |
size | 136,045 |
wasmcloud-provider-wit-bindgen
This crate contains a macro that helps build Wasmcloud Capability Providers which are distributed as binaries and work with the WIT.
This crate leverages wit-bindgen
in it's generation of interfaces and code, but generates pure Rust code (i.e. for non-wasm32-*
Rust targets) that can be used in building a capability provider binary.
This crate can be be used similarly to wit-bindgen
, with the following syntax:
wasmcloud_provider_wit_bindgen::generate!(
YourProvider,
"wasmcloud:contract",
"your-world"
);
/// Implementation that you will contribute
struct YourProvider;
impl Trait for YourProvider {
...
}
Note that arguments after the second are similar to the options used by wit-bindgen
, but the code generated is meant for use in a Rust binary, managed by a wasmcloud
host.
For example, to build a provider for the wasmCloud keyvalue WIT interface:
/// Generate bindings for a wasmCloud provider
wasmcloud_provider_wit_bindgen::generate!(
MyKeyvalueProvider,
"wasmcloud:keyvalue",
"keyvalue"
);
Warning You'll need to have the appropriate WIT interface file (ex.
keyvalue.wit
) in your crate root, at<crate root>/wit/keyvalue.wit
Note that after you generate bindings appropriate for your WIT, you must:
main.rs
that properly sets up your provider