A low-ish level tool for easily writing and hosting WASM based plugins.

Overview

A low-ish level tool for easily writing and hosting WASM based plugins.

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.

Loading a plugin is as simple as reading the .wasm file off disk.

let mut plugin = WasmPlugin::load("path/to/plugin.wasm")?;

Calling functions exported by the plugin takes one of two forms. Either the function takes no arguments and returns a single serde deserializable value:

let response: ResultType = plugin.call_function("function_name")?;

Or it takes a single serializable argument and returns a single result:

let message = Message::default();
let response: ResultType = plugin.call_function_with_argument("function_name", &message)?;

Exporting a function from a plugin is just a matter of wrapping it in a macro:

fn local_hello() -> String {
    "Hello, host!".to_string()
}
wasm_plugin_guest::export_plugin_function_with_no_input(hello, local_hello);

API Stability

I am not currently guaranteeing any stability, expect all releases to include breaking changes.

You might also like...
Annotation to easily define ad-hoc / one-shot extension traits

Annotation to easily define ad-hoc / one-shot extension traits

Convert Hygea calendar to an iCal file to easily import it to Google Calendar (Rust version)

Hygea to iCal Goal Hygea provides a calendar via PDF and an application called Recycle. I just wanted to use an iCal file to import it in my calendar.

Easily sync your clipboard between devices. This is a work in progress app.

Clipboard Sync Description Easily sync your clipboard between devices. This is a work in progress app. Stack Frontend: React Tauri isomorphic-ws TSX,

PM-Tools - a simple Rust util to easily create server directories

PM-Tools PM-Tools is a simple Rust util to easily create server directories or plugins without the hassle of unzipping or creating directories Progres

Easily customizable command runner made with Rust 🦀
Easily customizable command runner made with Rust 🦀

Easily customizable command runner made with Rust 🦀 📦 Usage Install by the following command: cargo install rxe Or build from the source. git clone

Easily add emojis to your git commit messages 😎
Easily add emojis to your git commit messages 😎

gimoji A CLI tool that makes it easy to add emojis to your git commit messages. It's very similar to (and is based on) gitmoji-cli but written in Rust

Cargo subcommand to easily bootstrap nocode applications. Write nothing; deploy nowhere.

cargo-nocode No code is the best way to write secure and reliable applications. Write nothing; deploy nowhere. cargo-nocode aims to bring the nocode a

hado-rshado — A little macro for writing haskell-like do expressions without too much ceremony

hado Monadic haskell-like expressions brought to rust via the hado! macro What? A little macro for writing haskell-like do expressions without too muc

A Rust macro for writing regex pattern matching.

regexm A Rust macro for writing regex pattern matching.

Comments
  • Wasmtime Support

    Wasmtime Support

    Hello, I came across this project, and I was interested in using it for prototyping my own, however I was planning on using wasmtime as my engine and see that this project only supports wasmer. Would you be up for changing, or accepting a change that adds wasmtime support?

    opened by XAMPPRocky 5
  • Generics for serializer selection

    Generics for serializer selection

    The feature based serializer selection is awkward to use and impossible for users to extend. It should be possible to do it via a type parameter on WasmPlugin and I think that would be a better approach.

    opened by alec-deason 0
  • Support Wasm hosts

    Support Wasm hosts

    When I initially did technology review on Wasmer I saw that they had a javascript package for working with wasm in browser. I made the, as it turns out, very incorrect assumption that that meant the Rust version of the Wasmer engine could itself be compiled to wasm and run in browser and that that would make supporting wasm_plugin in browser easy. I was wrong. Wasmer's JS support is a separate code base which means I will have to provide wasm support some other way, either by calling out to Wasmer's JS tools through my compatibility layer or by using the browser's wasmer api directly, not sure yet.

    opened by alec-deason 0
Owner
Alec Deason
Alec Deason
Build your service-server fast, easy (and without hosting!)

service-io is a library to build servers that offering services with really little effort. Choose an input connector. Choose an output connector. Choo

Luis Enrique Muñoz Martín 34 Jan 4, 2023
A stupidly simple and easy to self-host, personal server for file hosting on the web

Grasswave CDN A stupidly simple and easy to self-host, personal server for file hosting on the web. Written in Rust. Thanks, @Maciejowski, for the sty

Rafał Baran 3 Jan 3, 2023
A low-level I/O ownership and borrowing library

This library introduces OwnedFd, BorrowedFd, and supporting types and traits, and corresponding features for Windows, which implement safe owning and

Dan Gohman 74 Jan 2, 2023
Low level access to ATmega32U4 registers in Rust

Deprecation Note: This crate will soon be deprecated in favor of avr-device. The approach of generating the svd from hand-written register definitions

Rahix 9 Jan 27, 2021
A Wasm component optimizer (mostly a wrapper around wasm-opt)

component-opt An optimizer for Wasm Components Current Status This project currently only offers one optimization and does not allow it to be configur

Robin Brown 6 Mar 4, 2024
🦞 wasm-pack based build tool

rsw-rs This project is in early experimental stage. # dev rsw watch # release rsw build # create crate rsw new # rsw.toml name = 'rsw' version = "0.

lencx 71 Dec 30, 2022
A high level diffing library for rust based on diffs

Similar: A Diffing Library Similar is a dependency free crate for Rust that implements different diffing algorithms and high level interfaces for it.

Armin Ronacher 617 Dec 30, 2022
wasm actor system based on lunatic

Wactor WASM actor system based on lunatic. Actors run on isolated green threads. They cannot share memory, and communicate only through input and outp

Noah Corona 25 Nov 8, 2022
This crate allows writing a struct in Rust and have it derive a struct of arrays layed out in memory according to the arrow format.

Arrow2-derive - derive for Arrow2 This crate allows writing a struct in Rust and have it derive a struct of arrays layed out in memory according to th

Jorge Leitao 29 Dec 27, 2022
A rust library that makes reading and writing memory of the Dolphin emulator easier.

dolphin-memory-rs A crate for reading from and writing to the emulated memory of Dolphin in rust. A lot of internals here are directly based on aldela

Madison Barry 4 Jul 19, 2022