Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alec-deason/wasm_plugin
A low-ish level tool for easily writing and hosting WASM based plugins.
https://github.com/alec-deason/wasm_plugin
modding plugin wasm
Last synced: 9 days ago
JSON representation
A low-ish level tool for easily writing and hosting WASM based plugins.
- Host: GitHub
- URL: https://github.com/alec-deason/wasm_plugin
- Owner: alec-deason
- License: mit
- Archived: true
- Created: 2021-03-01T22:13:30.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-14T21:13:17.000Z (8 months ago)
- Last Synced: 2024-04-02T01:34:18.260Z (8 months ago)
- Topics: modding, plugin, wasm
- Language: Rust
- Homepage:
- Size: 177 KB
- Stars: 69
- Watchers: 3
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#OBSOLETE#
These crates are no longer maintained and the use case is better served by the [WebAssembly Component specification](https://component-model.bytecodealliance.org/language-support/rust.html).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.```rust
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:```rust
let response: ResultType = plugin.call_function("function_name")?;
```Or it takes a single serializable argument and returns a single result:
```rust
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:
```rust
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.