Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.
/ wasm_plugin Public archive

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

License

Notifications You must be signed in to change notification settings

alec-deason/wasm_plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#OBSOLETE# These crates are no longer maintained and the use case is better served by the WebAssembly Component specification.

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 = WasmPluginBuilder::from_file("path/to/plugin.wasm")?.finish()?;

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published