#actor #wasmcloud #api-bindings

wasmcloud-actor-keyvalue

为wasmCloud演员提供键值合约的接口

3个版本

0.2.2 2021年4月16日
0.2.1 2021年2月17日
0.2.0 2021年2月10日

1611WebAssembly

Download history • Rust 包仓库 126/week @ 2024-04-07 • Rust 包仓库 123/week @ 2024-04-14 • Rust 包仓库 61/week @ 2024-04-21 • Rust 包仓库 115/week @ 2024-04-28 • Rust 包仓库 105/week @ 2024-05-05 • Rust 包仓库 78/week @ 2024-05-12 • Rust 包仓库 54/week @ 2024-05-19 • Rust 包仓库 75/week @ 2024-05-26 • Rust 包仓库 107/week @ 2024-06-02 • Rust 包仓库 176/week @ 2024-06-09 • Rust 包仓库 69/week @ 2024-06-16 • Rust 包仓库 147/week @ 2024-06-23 • Rust 包仓库 75/week @ 2024-06-30 • Rust 包仓库 117/week @ 2024-07-07 • Rust 包仓库 130/week @ 2024-07-14 • Rust 包仓库 226/week @ 2024-07-21 • Rust 包仓库

每月下载 552
5 个Crates中使用(直接使用4个)

Apache-2.0

19KB
398

crates.io  Rust license  documentation

wasmCloud键值存储演员接口

本crate为演员提供与键值存储能力提供者通信的接口。使用此接口的演员必须拥有 wasmcloud:keyvalue 能力权限。

本crate是 单向 的,仅支持演员向主机调用。能力提供者不会向演员发送消息(例如,演员无法订阅存储更改事件)。

以下是一个示例用法

#[macro_use]
extern crate serde_json;
extern crate wasmcloud_actor_http_server as http;
extern crate wasmcloud_actor_keyvalue as kv;
extern crate wasmcloud_actor_core as actor;

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

#[macro_use]
extern crate serde_json;

#[actor::init]
pub fn init() {
    http::Handlers::register_handle_request(increment_counter);
}

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

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

依赖

~1.2–2.2MB
~46K SLoC