Crate wasm_plugin_guest

Source
Expand description

A low-ish level tool for easily writing WASM based plugins to be hosted by wasm_plugin_host.

The goal of wasm_plugin is to make communicating across the host-plugin boundary as simple and idiomatic as possible while being unopinionated about how you actually use the plugin.

This crate currently supports serialization either using bincode or json selected by feature: serialize_bincode: Uses serde and bincode. It is selected by default. serialize_json: Uses serde and serde_json. `serialize_nanoserde_json’: Uses nanoserde.

Bincode is likely the best choice if all plugins the system uses will be written in Rust. Json is useful if a mix or languages will be used.

Plugins are meant to be run using wasm_plugin_host

Macros§

import_functions
Import functions from the host program. The function’s arguments an return type must all be serializable. Several functions can be imported at once by listing their signatures seperated by ;

Functions§

allocate_message_buffer
Allocate a buffer suitable for writing messages to and return it’s address.
free_message_buffer
Frees a previously allocated buffer.
read_message
Read a message from a buffer created with allocate_message_buffer. You should never need to call this directly.
write_message
Write a message to the buffer used to communicate with the host. You should never need to call this directly.

Attribute Macros§

export_function
Builds an extern function which will handle serializing and deserializing of arguments and return values of the function it is applied to. The function must take only deserializable arguments and return a serializable result.