Skip to main content

PluginLoader

Struct PluginLoader 

Source
pub struct PluginLoader { /* private fields */ }
Expand description

Owner of all loaded plugin cdylibs.

See the module docs for the lifetime / RT-safety contract.

Implementations§

Source§

impl PluginLoader

Source

pub fn new() -> Self

Construct an empty loader.

Source

pub fn load(&mut self, path: &Path) -> Result<PluginId>

Load and ABI-verify a plugin cdylib, returning its assigned id.

§Steps
  1. Validate the path (must be an existing, readable file).
  2. dlopen the library.
  3. Look up and call audio_plugin_abi_magic; require AUDIO_PLUGIN_ABI_MAGIC.
  4. Look up and call audio_plugin_abi_version; require a major match (see is_abi_compatible).
  5. Look up audio_plugin_metadata and copy out an owned PluginMetadata.
  6. Look up audio_plugin_create (required) and audio_plugin_destroy (optional).
  7. Register the plugin under a fresh PluginId.

Loading the same path twice is permitted: each call receives its own id and its own dlopen handle.

§Errors
Source

pub fn unload(&mut self, id: PluginId) -> Result<()>

Unload a plugin, dropping its library (dlclose).

The caller must ensure no AudioNode instantiated from this plugin is still alive — the adapter owns an opaque handle into the plugin’s memory and calling it after dlclose is undefined behaviour.

§Errors

Returns PluginError::NotLoaded when id is not registered.

Source

pub fn get(&self, id: PluginId) -> Result<&LoadedPlugin>

Borrow a loaded plugin by id.

§Errors

Returns PluginError::NotLoaded when id is not registered.

Source

pub fn get_mut(&mut self, id: PluginId) -> Result<&mut LoadedPlugin>

Mutably borrow a loaded plugin by id.

§Errors

Returns PluginError::NotLoaded when id is not registered.

Source

pub fn metadata(&self, id: PluginId) -> Result<&PluginMetadata>

Metadata for a loaded plugin.

§Errors

Returns PluginError::NotLoaded when id is not registered.

Source

pub fn instantiate(&mut self, id: PluginId) -> Result<Box<dyn AudioNode>>

Instantiate a fresh AudioNode from a loaded plugin.

Runs on the setup thread; the returned node is then moved onto the RT thread by the caller.

§Errors

Returns PluginError::NotLoaded when id is not registered.

Source

pub fn is_loaded(&self, id: PluginId) -> bool

true when id is currently loaded.

Source

pub fn len(&self) -> usize

Number of plugins currently loaded.

Source

pub fn is_empty(&self) -> bool

true when no plugins are loaded.

Source

pub fn ids(&self) -> Vec<PluginId>

All currently-registered plugin ids.

The order is unspecified (iteration order of the internal map).

Trait Implementations§

Source§

impl Default for PluginLoader

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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, 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, 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.