GitHub Actions GitHub Releases

plugy

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.

Features

Getting Started

To use plugy in your Rust project, follow these steps:

  1. Write your plugin trait:

```rust

[plugy::plugin]

trait Greeter { fn greet(&self) -> String; } ```

  1. Write your first plugin implementation

```rust

[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

  1. Import and run

```rust

[pluginimport(file = "target/wasm32-unknown-unknown/debug/fooplugin.wasm")]

struct FooPlugin;

[tokio::main]

async fn main() { let runtime = Runtime::>::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!

Examples

Check out the examples directory for sample usage of plugy.

Milestones

| Status | Goal | Labels | | :----: | :-------------------------------------------------------------------------------------------------- | ---------- | | ✅ | accept multiple arity (n-ary) in plugin functions | complete | | ✅ | pass down context between host and guest | complete |

Functionality

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.

Contributing

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.

Thanks to

License

This project is licensed under the GNU General Public License.