escouade-plugin-protocol 0.1.1

The JSON-RPC protocol of Escouade's plugins: its constants, its messages and the loop of a plugin, in process or as a WASM module
Documentation

escouade-plugin-protocol

The protocol Escouade speaks to its plugins: JSON-RPC 2.0, one message a line. This crate holds what both sides share: the version, the methods, the messages of the handshake and of the extension points.

A plugin that answers at once, a state machine, needs nothing else, and the same source compiles in process and for wasm32-wasip1:

use escouade_plugin_protocol::{turn, Refusal};
use serde_json::{json, Value};

pub fn run() -> i32 {
    turn::run("example", json!({}), |method, _params: Value| {
        Err(Refusal::not_found(method))
    })
}

escouade_plugin_protocol::module!(run);

turn also gives what std cannot give a module: turn::instance_id() in place of std::process::id(), and turn::read_file() in place of std::fs.

A plugin whose calls wait on the network will rather take escouade-plugin-kit.

The reference of the plugins: https://escouade.dev/en/docs/plugins/api. The code is in Escouade's repository. This crate is under the MIT licence; the app is under GPL-3.0-or-later.