wasmcloud-provider-wit-bindgen-macro

Crates.iowasmcloud-provider-wit-bindgen-macro
lib.rswasmcloud-provider-wit-bindgen-macro
version0.1.1
sourcesrc
created_at2024-03-27 18:30:25.632558
updated_at2024-03-27 18:30:25.632558
descriptionInternal-use bindgen macro for binary-based wasmCloud capability providers written in Rust
homepage
repositoryhttps://github.com/wasmCloud/wasmCloud
max_upload_size
id1188268
size136,045
wasmCloud Automation Bot (wasmcloud-automation)

documentation

README

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.

Usage

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:

  • follow the compiler to implement the appropriate traits
  • write a main.rs that properly sets up your provider
  • use the compiled binary for your provider on your wasmCloud lattice
Commit count: 5943

cargo fmt