Skip to main content

NativePluginLoader

Struct NativePluginLoader 

Source
pub struct NativePluginLoader;
Expand description

Loader for native plugins.

Provides methods to load plugins from shared libraries or bundles.

Implementations§

Source§

impl NativePluginLoader

Source

pub fn load<P: AsRef<Path>>(path: P) -> ConsumerResult<NativePlugin>

Load a plugin from a shared library path.

Uses default configuration and no log callback.

§Arguments
  • path - Path to the shared library (.so, .dylib, or .dll)
§Example
let plugin = NativePluginLoader::load("target/release/libmy_plugin.so")?;
Source

pub fn load_with_config<P: AsRef<Path>>( path: P, config: &PluginConfig, log_callback: Option<LogCallbackFn>, ) -> ConsumerResult<NativePlugin>

Load a plugin with custom configuration.

§Arguments
  • path - Path to the shared library
  • config - Plugin configuration
  • log_callback - Optional callback to receive log messages
§Example
let config = PluginConfig::default();
let log_callback: LogCallbackFn = Arc::new(|level, target, msg| {
    println!("[{level}] {target}: {msg}");
});

let plugin = NativePluginLoader::load_with_config(
    "target/release/libmy_plugin.so",
    &config,
    Some(log_callback),
)?;
Source

pub fn load_bundle<P: AsRef<Path>>( bundle_path: P, ) -> ConsumerResult<NativePlugin>

Load a plugin from a bundle file.

Extracts the library for the current platform and loads it.

§Arguments
  • bundle_path - Path to the .rbp bundle file
§Example
let plugin = NativePluginLoader::load_bundle("my-plugin-1.0.0.rbp")?;
Source

pub fn load_bundle_with_config<P: AsRef<Path>>( bundle_path: P, config: &PluginConfig, log_callback: Option<LogCallbackFn>, ) -> ConsumerResult<NativePlugin>

Load a plugin from a bundle with custom configuration.

§Arguments
  • bundle_path - Path to the .rbp bundle file
  • config - Plugin configuration
  • log_callback - Optional callback to receive log messages
§Example
let config = PluginConfig::default();
let plugin = NativePluginLoader::load_bundle_with_config(
    "my-plugin-1.0.0.rbp",
    &config,
    None,
)?;
Source

pub fn load_bundle_variant_with_config<P: AsRef<Path>>( bundle_path: P, variant: &str, config: &PluginConfig, log_callback: Option<LogCallbackFn>, ) -> ConsumerResult<NativePlugin>

Load a specific variant from a bundle with custom configuration.

Unlike load_bundle_with_config which always extracts the default (release) variant, this method extracts the named variant (e.g., “debug”, “release”).

§Arguments
  • bundle_path - Path to the .rbp bundle file
  • variant - Variant name (e.g., “release”, “debug”)
  • config - Plugin configuration
  • log_callback - Optional callback to receive log messages
§Example
let config = PluginConfig::default();
let plugin = NativePluginLoader::load_bundle_variant_with_config(
    "my-plugin-1.0.0.rbp",
    "debug",
    &config,
    None,
)?;
Source

pub fn load_bundle_to_dir<P: AsRef<Path>, Q: AsRef<Path>>( bundle_path: P, extract_dir: Q, config: &PluginConfig, log_callback: Option<LogCallbackFn>, ) -> ConsumerResult<NativePlugin>

Load a plugin from a bundle to a specific extraction directory.

This is useful when you want to control where the library is extracted.

§Arguments
  • bundle_path - Path to the .rbp bundle file
  • extract_dir - Directory to extract the library to
  • config - Plugin configuration
  • log_callback - Optional callback to receive log messages
Source

pub fn load_bundle_with_verification<P: AsRef<Path>>( bundle_path: P, config: &PluginConfig, log_callback: Option<LogCallbackFn>, verify_signatures: bool, public_key_override: Option<&str>, ) -> ConsumerResult<NativePlugin>

Load a plugin from a bundle with signature verification.

§Arguments
  • bundle_path - Path to the .rbp bundle file
  • config - Plugin configuration
  • log_callback - Optional callback to receive log messages
  • verify_signatures - Whether to verify minisign signatures
  • public_key_override - Optional public key to use instead of manifest’s key
§Example
// Load with signature verification (recommended for production)
let plugin = NativePluginLoader::load_bundle_with_verification(
    "my-plugin-1.0.0.rbp",
    &PluginConfig::default(),
    None,
    true,  // verify signatures
    None,  // use manifest's public key
)?;
Source

pub fn load_by_name(name: &str) -> ConsumerResult<NativePlugin>

Load a plugin by name, searching standard library paths.

Searches for the library in:

  1. Current directory
  2. ./target/release
  3. ./target/debug
  4. System library paths (LD_LIBRARY_PATH on Linux, etc.)
§Arguments
  • name - Library name without prefix/suffix (e.g., “myplugin” finds “libmyplugin.so”)
§Example
// Searches for libmyplugin.so (Linux), libmyplugin.dylib (macOS), myplugin.dll (Windows)
let plugin = NativePluginLoader::load_by_name("myplugin")?;
Source

pub fn load_by_name_with_config( name: &str, config: &PluginConfig, log_callback: Option<LogCallbackFn>, ) -> ConsumerResult<NativePlugin>

Load a plugin by name with custom configuration.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more