crates.io  Rust license  documentation

wasmCloud Messaging Actor Interface

This crate provides wasmCloud actors with an interface to the Messaging capability provider. Actors using this interface must have the claim wasmcloud:messaging in order to have permission to handle messages, publish and perform request-response actions. They also must have an active, configured binding to a Messaging capability provider.

Example:

```rust extern crate wasmcloudactormessaging as messaging; extern crate wasmcloudactorcore as core; extern crate wapc_guest as guest; use guest::prelude::*;

[no_mangle]

pub fn wapcinit() { core::Handlers::registerhealthrequest(health); messaging::Handlers::registerhandlemessage(handlemessage); }

/// Reply to a "ping" message with "pong" fn handlemessage(message: messaging::BrokerMessage) -> HandlerResult<()> { if String::fromutf8(message.body)? == "ping".tostring() { messaging::default().publish(message.replyto, "".tostring(), "pong".tostring().into_bytes())?; } Ok(()) }

fn health(_: core::HealthCheckRequest) -> HandlerResult { Ok(core::HealthCheckResponse::healthy())
} ```