crates.io  Rust license  documentation

wasmCloud Key Value Store Actor Interface

This crate provides an interface for actors to use to communicate with a key-value store capability provider. Actors using this interface must have the wasmcloud:keyvalue capability permission.

This crate is one-way, and only supports actors making calls to the host. The capability provider does not deliver messages to actors (e.g. actors cannot subscribe to store change events).

The following is an example usage:

```rust

[macro_use]

extern crate serdejson; extern crate wasmcloudactorhttpserver as http; extern crate wasmcloudactorkeyvalue as kv; extern crate wasmcloudactorcore as actor;

use http::{self, Request, Response}; use wascap_guest::HandlerResult;

[macro_use]

extern crate serde_json;

[actor::init]

pub fn init() { http::Handlers::registerhandlerequest(increment_counter); }

fn incrementcounter(msg: Request) -> HandlerResult { let key = msg.path.replace('/', ":"); let resp = kv::default().add(key.tostring(), 1)?;

let result = json!({"counter": resp.value });
Ok(Response::json(result, 200, "OK")?)

} ```