Host calls

The plugin bus

Calling another plugin, publishing news, and asking whether a plugin is running.

Generated by tools/gen_api_docs.py; do not edit by hand. See host calls for how a call is made and how values are encoded. Each example shows the shape of a Wasm request with its required fields; the values in it are illustrative.

CallWhat it does
plugin_stateWhat became of the plugin called name: running; stopped, when it was unloaded or its file is in the plugin folder and it is not loaded; none, when there is no such plugin.
plugin_callThe plugin bus: a request from plugin to the plugin named target, answered at once.
plugin_emitThe plugin bus: news from plugin on topic, to every other plugin listening.

plugin_state

fn plugin_state(name: &str) -> String

What became of the plugin called name: running; stopped, when it was unloaded or its file is in the plugin folder and it is not loaded; none, when there is no such plugin.

Wasm request

FieldTypeRequired
namestringyes

Reply: {"ok": ...} holding the Rust return value String, encoded as in conventions.

{"call": "plugin_state", "name": "Steve"}

plugin_call

fn plugin_call(plugin: &str, target: &str, request: &Data) -> Result<Option<Data>, String>

The plugin bus: a request from plugin to the plugin named target, answered at once. Ok(None) is a target that had nothing to say; an error names why there was no answer -- no such plugin, or a call back into one that is still answering.

Wasm request

FieldTypeRequired
targetstringyes
requestJSON value, read into the Rust parameter request: &Data; see the doc commentno

Router notes: The sender is the manifest's name, as for store: a guest cannot speak for another. plugin is never sent by a Wasm guest: the server fills it in from the manifest name.

Reply: {"ok": ...} holding the Rust return value Result<Option<Data>, String>, encoded as in conventions. An Err arrives as {"error": "..."}.

{"call": "plugin_call", "target": "economy"}

plugin_emit

fn plugin_emit(plugin: &str, topic: &str, data: &Data) -> u32

The plugin bus: news from plugin on topic, to every other plugin listening. Answers how many heard it.

Wasm request

FieldTypeRequired
topicstringyes
dataJSON value, read into the Rust parameter data: &Data; see the doc commentno

Router notes: plugin is never sent by a Wasm guest: the server fills it in from the manifest name.

Reply: {"ok": ...} holding the Rust return value u32, encoded as in conventions.

{"call": "plugin_emit", "topic": "claims.changed"}

From docs/api/reference/host-calls/bus.md in the RustMC repository at bbd81209ad.