| Crates.io | plux-rs |
| lib.rs | plux-rs |
| version | 1.1.2 |
| created_at | 2025-09-09 12:51:00.098504+00 |
| updated_at | 2026-01-14 15:51:56.256117+00 |
| description | A modular and performant plugin system for Rust applications, enabling secure and stable extension of functionality through external plugins. |
| homepage | https://github.com/BleynChannel/plux-rs |
| repository | https://github.com/BleynChannel/plux-rs |
| max_upload_size | |
| id | 1830750 |
| size | 426,726 |
Plux is a comprehensive plugin system for Rust applications, offering a robust and flexible architecture for extending application functionality through plugins. Designed with modularity and performance in mind, Plux enables seamless integration of third-party code while maintaining security and stability.
Plux is built on a modular architecture that separates concerns between different components, enabling flexible and maintainable plugin management.
Self-contained modules that extend application functionality. Each plugin includes:
The central component responsible for:
Specialized adapters that provide:
Add this to your Cargo.toml:
[dependencies]
plux-rs = "1.1.2"
Cargo.toml:[dependencies]
plux-rs = "1.1.2"
plux-lua-manager = "0.1" # For running Lua plugins
use plux_rs::prelude::*;
use plux_lua_manager::LuaManager;
// Declare a function that will be available to all plugins
// The `derive` feature is required for the `plux_rs::function` macro
#[plux_rs::function]
fn add(_: (), a: &i32, b: &i32) -> i32 {
a + b
}
fn main() {
// Create a new plugin loader
let mut loader = SimpleLoader::new();
// Configure the loader with context
loader.context(move |mut ctx| {
// Register the plugin manager
// You can register multiple managers for different plugin types (Lua, Rust, WASM, etc.)
ctx.register_manager(LuaManager::new())?;
// Register functions that will be available to plugins
ctx.register_function(add());
// Define a request that plugins must implement
ctx.register_request(Request::new("main".to_string(), vec![], None));
Ok::<(), Box<dyn std::error::Error>>(())
}).unwrap();
// Load a single plugin
// Format: {id}-v{version}.{format}
// The format is determined by the plugin manager (e.g., "lua" for LuaManager)
let bundle = loader.load_plugin_now("my_plugin-v1.0.0.lua").unwrap();
// Alternatively, load multiple plugins at once
loader.load_plugins(vec![
"calculator-v1.0.0.lua",
"logger-v1.0.0.lua",
"paint-v1.0.0.lua",
]).unwrap();
// Access a loaded plugin by its bundle name
let plugin = loader.get_plugin_by_bundle(&bundle).unwrap();
println!("Plugin loaded - Path: {:?}, Bundle: {}",
plugin.info().path,
plugin.info().bundle);
// Call the 'main' request defined in the plugin
if let Err(e) = plugin.call_request("main", &[]).unwrap() {
eprintln!("Plugin error: {}", e);
}
// Call a function exposed by the plugin
if let Ok(Some(result)) = plugin.call_function("echo", &["Hello world".into()]).unwrap() {
println!("Plugin responded: {}", result);
}
// Unload the plugin when done (optional)
loader.unload_plugin_by_bundle(&bundle).unwrap();
// Stop the loader (optional)
loader.stop().unwrap();
}
To create a custom plugin manager, implement the Manager trait.
For a complete example, see examples/custom_manager.rs in the repository.
The Plux repository includes several examples to help you get started:
Each example includes detailed comments and can be run using Cargo:
cargo run --example basic_plugin
Plux provides several feature flags to customize functionality:
full - Enables all features (recommended for most use cases)default - Includes essential features for basic plugin functionalityderive - Enables derive macros for implementing plugin traits
#[plux_rs::function] - Expose Rust functions to pluginsarchive - Adds support for packaging plugins as zip archives
plux_rs::utils::archive::zip - Bundle plugin files into an archiveplux_rs::utils::archive::unzip - Extract plugin files from an archive[!WARNING] There is currently none. It will be implemented in 2.0.
serde - Enables serialization/deserialization of plugin data
Serialize and Deserialize[!WARNING] There is currently none. It will be implemented in 2.0.
async - Enables async/await support for plugin operations
[!WARNING] There is currently none. It will be implemented in 2.0.
log - Integrates with the log crate for plugin logging
Plux supports various plugin types through specialized managers: