Expand description
Rust consumer for rustbridge plugins.
This crate enables Rust applications to dynamically load and invoke rustbridge
plugin bundles (.rbp files) or shared libraries at runtime. It provides the
same functionality available to Java, Kotlin, C#, and Python consumers.
§Features
- Dynamic Loading: Load plugins at runtime without compile-time linking
- Bundle Support: Load from
.rbpbundles with automatic platform detection - Signature Verification: Verify minisign signatures on bundles
- JSON Transport: Make calls using JSON serialization
- Binary Transport: High-performance binary struct transport (7x faster)
- Lifecycle Management: Full OSGI-inspired lifecycle state machine
- Logging Integration: Route plugin logs through host callbacks
§Quick Start
ⓘ
use rustbridge_consumer::{NativePluginLoader, ConsumerResult};
fn main() -> ConsumerResult<()> {
// Load a plugin
let plugin = NativePluginLoader::load("target/release/libmy_plugin.so")?;
// Make a call
let response = plugin.call("echo", r#"{"message": "Hello"}"#)?;
println!("Response: {response}");
Ok(())
}§Loading from Bundles
ⓘ
use rustbridge_consumer::{NativePluginLoader, PluginConfig};
let config = PluginConfig::default();
let plugin = NativePluginLoader::load_bundle_with_config(
"my-plugin-1.0.0.rbp",
&config,
None,
)?;§Loading with Signature Verification
ⓘ
use rustbridge_consumer::{NativePluginLoader, PluginConfig};
// Load with signature verification (recommended for production)
let plugin = NativePluginLoader::load_bundle_with_verification(
"my-plugin-1.0.0.rbp",
&PluginConfig::default(),
None, // no log callback
true, // verify signatures
None, // use manifest's public key
)?;§Typed Calls
ⓘ
use serde::{Serialize, Deserialize};
#[derive(Serialize)]
struct EchoRequest { message: String }
#[derive(Deserialize)]
struct EchoResponse { message: String, length: usize }
let response: EchoResponse = plugin.call_typed("echo", &EchoRequest {
message: "Hello".to_string(),
})?;Modules§
- prelude
- Prelude module for convenient imports.
Structs§
- Native
Plugin - A loaded native plugin that can be called via FFI.
- Native
Plugin Loader - Loader for native plugins.
- Plugin
Config - Plugin configuration passed during initialization
Enums§
- Consumer
Error - Errors that can occur when loading or calling plugins.
- Lifecycle
State - Plugin lifecycle states following OSGI-inspired model
- LogLevel
- Log levels for FFI callbacks
- Plugin
Error - Error type for plugin operations
Type Aliases§
- Consumer
Result - Result type for consumer operations.
- LogCallback
Fn - Rust-friendly log callback type.