Crate dygpi[][src]

Expand description

Provides support for Dynamic Generic PlugIns, library based plugins for Rust.

This crate implements a simple plugin model that allows for loading of implementations from external dynamic libraries at runtime.

  1. The plugin host defines a concrete type, the plugin type.
    1. The plugin type MUST implement the trait Plugin.
    2. It MAY be preferable to define the plugin type in a separate plugin API crate that both the host and provider depend upon.
  2. The plugin provider (or library) crate MUST set crate-type to "dylib" and "rlib" in their cargo configuration.
  3. The plugin provider MUST implement a function, named register_plugins, which is passed a registrar object to register any instances of the plugin type.
    1. A plugin provider can use an alternate name for the registration function but this must be provided to the plugin manager via the set_registration_fn_name method.
  4. The plugin host then uses the PluginManager to load libraries, and register plugins, that have the same type as the plugin type.
  5. The plugin host MAY then use plugin manager’s get method to fetch a specific plugin by id, OR use plugin manager’s plugins method to iterate over all plugins.

Overriding the plugin registration function allows a plugin host to provide plugins of different types by using separate registration functions for each type.


The example below shows the plugin manager loading any plugins from a specific library and then retrieving a single plugin by ID from the loaded set.

use dygpi::manager::PluginManager;
use dygpi::plugin::Plugin;
use std::sync::Arc;

fn main() {
    let mut plugin_manager: PluginManager<SoundEffectPlugin> = PluginManager::default();


    let plugin: Arc<SoundEffectPlugin> = plugin_manager

    println!("{}", plugin.plugin_id());;


config_serde: Adds Serde’s Serialize and Deserialize traits to the PluginManagerConfiguration type so that it can be used in configuration files.

source = ["analog_oscillator", "lfo"]
effect = ["delay", "reverb"]


Provides a configuration type that can be used to map a plugin type identifier to a list of library paths. The result is the ability to create plugin manager instances from this configuration without having to load all the plugin provider paths programmatically.

Provides the Error, ErrorKind, and Result type used in the rest of this crate.

The components required by a plugin host to load/unload plugins.

The components required to define a plugin API.