Expand description
Malbox Plugin SDK
This crate is the foundation for building plugins for Malbox.
Plugins come in two flavors:
- Host plugins run on the daemon and communicate over IPC. Mark your
struct with
#[malbox::host_plugin]. - Guest plugins run inside a sandboxed environment and communicate over gRPC.
Mark your struct with
#[malbox::guest_plugin].
In both cases, you write handler methods and annotate them with
#[malbox::on_task],
#[malbox::on_start],
#[malbox::on_stop], or
#[malbox::on_event(...)].
The SDK generates the boilerplate: trait impls, fn main,
runtime setup, and result transport.
Package metadata (name, version, description, authors) is read
automatically from your Cargo.toml, so you only need to specify
state and execution in the attribute.
§Example
ⓘ
extern crate malbox_plugin_sdk as malbox;
use malbox::prelude::*;
#[malbox::host_plugin]
#[malbox(state = "persistent", execution = "parallel")]
struct MyPlugin;
#[malbox::handlers]
impl MyPlugin {
#[malbox::on_task]
fn analyze(&self, ctx: &Context) -> Result<()> {
Ok(())
}
}Re-exports§
pub use context::Context;pub use context::ResultSink;pub use context::TaskInfo;pub use error::Result;pub use error::SdkError;pub use health::HealthStatus;pub use meta::ExecutionContext;pub use meta::PluginMeta;pub use meta::PluginState;pub use plugin::GuestPlugin;pub use plugin::HostPlugin;pub use plugin::LaunchResult;pub use plugin::Plugin;pub use report::Report;pub use report::ReportBuilder;pub use report::SCHEMA_VERSION;pub use report::SectionBuilder;pub use report::Verdict;pub use result::PluginResult;
Modules§
- context
- Plugin execution context.
- error
- Error types for the plugin SDK.
- health
- Plugin health status.
- meta
- Plugin metadata: identity, lifecycle behavior, and concurrency model.
- plugin
- Core plugin traits.
- prelude
- Everything a plugin needs in scope. Start with
use malbox::prelude::*;. - report
- The
Reportenvelope - a structured, frontend-renderable result. - result
- Named results produced by plugin analysis.
- runtime
- Runtime implementations that run a
HostPluginagainst a transport. - stash 🔒
- Disk-backed result stash for large guest-plugin results.
- testkit
- Test-only constructors for SDK types.
Constants§
- REPORT_
RESULT_ NAME - The well-known
result_namethe scheduler and API use to identify a report envelope among a task’s outputs. Defined inmalbox-plugin-transportso the SDK and scheduler share the same constant without a direct dep. Well-knownresult_namefor a plugin’s structured report envelope.
Attribute Macros§
- guest_
plugin - Marks a struct as a guest plugin (gRPC-based, runs inside VM).
- handlers
- Applied to an
implblock to scan for handler methods and generate trait impls. - health_
check - Marks a method as a custom health check handler (used inside
#[malbox::handlers]). - host_
plugin - Marks a struct as a host plugin (IPC-based, runs on daemon host).
- on_
event - Marks a method as an event handler (used inside
#[malbox::handlers]). - on_
start - Marks a method as the startup handler (used inside
#[malbox::handlers]). - on_stop
- Marks a method as the shutdown handler (used inside
#[malbox::handlers]). - on_task
- Marks a method as the task handler (used inside
#[malbox::handlers]).