Crates.io | plugy |
lib.rs | plugy |
version | 0.3.1 |
source | src |
created_at | 2023-08-08 17:54:43.657832 |
updated_at | 2023-12-14 18:12:17.757198 |
description | plugy empowers you to construct agnostic dynamic plugin systems using Rust and WASM |
homepage | |
repository | https://github.com/geofmureithi/plugy |
max_upload_size | |
id | 939400 |
size | 13,365 |
plugy is a plugin system designed to enable the seamless integration of Rust-based plugins into your application. It provides a runtime environment for loading and executing plugins written in WebAssembly (Wasm), enabling dynamic extensibility and modularity in your Rust projects.
To use plugy in your Rust project, follow these steps:
#[plugy::plugin]
trait Greeter {
fn greet(&self) -> String;
}
#[derive(Debug, Deserialize)]
struct FooPlugin;
#[plugin_impl]
impl Greeter for FooPlugin {
fn greet(&self) -> String {
"Hello From Foo Plugin".to_owned()
}
}
Compile it!
cargo build --target wasm32-unknown-unknown
#[plugin_import(file = "target/wasm32-unknown-unknown/debug/foo_plugin.wasm")]
struct FooPlugin;
#[tokio::main]
async fn main() {
let runtime = Runtime::<Box<dyn Greeter>>::new().unwrap();
let handle = runtime.load(FooPlugin).await.unwrap();
let res = handle.greet().await;
assert_eq!(res, "Hello From Foo Plugin")
}
And you are set!
Check out the examples directory for sample usage of plugy.
Status | Goal | Labels |
---|---|---|
✅ | accept multiple arity (n-ary) in plugin functions | complete |
✅ | pass down context between host and guest | complete |
Plugy comprises three fundamental crates, each serving a distinct role in crafting dynamic plugin systems with Rust and WebAssembly:
core: This crate houses essential components such as bitwise utilities and the guest module, forming the foundation of Plugy's functionality.
runtime: The runtime crate orchestrates the execution of your plugin system, allowing seamless integration of plugins into your applications.
macros: The macros crate offers a collection of macros that simplify the generation of bindings and interfaces, streamlining the process of working with dynamic plugins.
Contributions to plugy are welcome! If you find a bug or want to propose a new feature, feel free to create an issue or submit a pull request.
License
This project is licensed under the MIT OR Apache-2.0 License.