| Crates.io | lp |
| lib.rs | lp |
| version | 0.2.5 |
| created_at | 2025-06-09 22:52:14.131734+00 |
| updated_at | 2025-12-01 08:25:13.388389+00 |
| description | An embeddable plugin system for Rust applications. |
| homepage | |
| repository | https://github.com/chrispaig3/lp |
| max_upload_size | |
| id | 1706453 |
| size | 19,353 |
An embeddable plugin system for Rust applications.
Still under early development; I would recommend against using it for anything serious at the moment.
use lp::{PluginManager, Toml};
fn main() {
let toml = Toml::parse("plugin_manifest.toml")
.expect("Failed to parse plugin manifest");
toml.plugin.use_plugin(|plugin| {
// custom logic to handle executing the plugin
});
}
// add to your project: cargo add lp -F dynamic-loading
use lp::{
PluginManager, Toml,
load::{Lib, Loadable, Symbol},
};
fn main() {
let hello_symbol = "hello_fn";
let toml = Toml::parse("plugin.toml").expect("File not found");
toml.plugin.use_plugin(|plugin| {
type UnsafeFn = unsafe extern "C" fn() -> *const std::ffi::c_char;
if let Some(path) = &plugin.path {
let hello_lib = unsafe {
Lib::<Symbol<'static, UnsafeFn>>::load(path, hello_symbol)
.expect("Failed to load hello function")
};
if let Some(hello_fn) = &hello_lib.f {
let result = unsafe { hello_fn() };
println!("hello function loaded!");
println!("{}", unsafe {
std::ffi::CStr::from_ptr(result).to_string_lossy()
});
}
}
});
}
[plugin]
name = "example"
version = "0.1.0"
authors = ["Author Name"]
description = "An example plugin"
license = "MIT"
path = "/path/to/plugin"
Ron(
plugin: Plugin(
name: "example",
version: "0.1.0",
authors: Some(["Author Name"]),
description: Some("An example plugin"),
license: Some("MIT"),
path: Some("/path/to/plugin"),
),
)
{
"plugin": {
"name": "example",
"version": "0.1.0",
"authors": ["Author Name"],
"description": "An example plugin",
"license": "MIT",
"path": "/path/to/plugin"
}
}