2 releases
new 0.1.1 | Jan 15, 2025 |
---|---|
0.1.0 | Jan 15, 2025 |
#1135 in Development tools
102 downloads per month
12KB
85 lines
plugrs
A lightweight and type-safe plugin system for Rust.
Features
- Type-safe plugin interface
- Dynamic plugin loading
- Thread-safe plugin execution
- Procedural macros for plugin development
- Error handling and recovery
- Zero-cost abstractions
Usage
Add this to your Cargo.toml
:
[dependencies]
plugrs = "0.1.0"
Example
Creating a plugin:
use plugrs::prelude::*;
#[plugin]
pub struct MyPlugin;
impl Plugin for MyPlugin {
fn name(&self) -> String {
"My Plugin".to_string()
}
fn execute(&self) -> i32 {
42
}
}
Loading and using plugins:
use plugrs::PluginManager;
fn main() {
let manager = PluginManager::new();
// Load a plugin from a dynamic library
let plugin = manager.load_plugin("path/to/plugin.so").unwrap();
// Execute the plugin
let result = plugin.execute();
println!("Plugin result: {}", result);
}
License
This project is licensed under the MIT License - see the LICENSE file for details.
Dependencies
~0.3–1MB
~17K SLoC