Warning: experimental project, things might change soon
This tool helps you build a plugin infrastructure for your Rust project. Highlights of that system:
The rust-plugin-test project is an example of this usage.
Launch the following command:
cargo install cargo-plugin
This will work better if your project uses a workspace:
plugin-api
crate defines traits that plugins should implement
cargo-plugin
expects that this crates exposes a PluginInformation
traitplugins
crate holds the plugins
Cargo.toml
file declares a dependency on plugin-api
by version. This file will be rewritten by cargo-plugin
metadata.toml
file indicates the plugin API crate's nameplugins/src
:metadata.toml
file declaring its name and its dependenciesmod.rs
file:
PLUGIN_METADATA
const element that implements the PluginInformation
traitmain
crate:
You can now publish your crates, first the plugin API, then the plugins crate, then the main one.
Your crates are published with a default set of plugins. If you want to build a version with a different set of plugins, add and remove plugin folders in plugins/src
, then run cargo plugin
while in plugins/
.
The cargo-plugin
tool will read the metadata from every plugin folder, then edit the Cargo.toml
and src/lib.rs
to do the following tasks: