pub struct PluginsManager<StartArgs: PluginStartArgs, Instance: PluginInstance> { /* private fields */ }
Expand description
A plugins manager that handles starting and stopping plugins.
Plugins can be loaded from shared libraries using Self::declare_dynamic_plugin_by_name
or Self::declare_dynamic_plugin_by_paths
, or added directly from the binary if available using Self::declare_static_plugin
.
Implementations§
Source§impl<StartArgs: PluginStartArgs + 'static, Instance: PluginInstance + 'static> PluginsManager<StartArgs, Instance>
impl<StartArgs: PluginStartArgs + 'static, Instance: PluginInstance + 'static> PluginsManager<StartArgs, Instance>
Sourcepub fn dynamic<S: Into<String>>(
loader: LibLoader,
default_lib_prefix: S,
) -> Self
pub fn dynamic<S: Into<String>>( loader: LibLoader, default_lib_prefix: S, ) -> Self
Constructs a new plugin manager with dynamic library loading enabled.
Sourcepub fn static_plugins_only() -> Self
pub fn static_plugins_only() -> Self
Constructs a new plugin manager with dynamic library loading disabled.
Sourcepub fn declare_static_plugin<P: Plugin<StartArgs = StartArgs, Instance = Instance> + Send + Sync, S: Into<String>>(
&mut self,
id: S,
required: bool,
)
pub fn declare_static_plugin<P: Plugin<StartArgs = StartArgs, Instance = Instance> + Send + Sync, S: Into<String>>( &mut self, id: S, required: bool, )
Adds a statically linked plugin to the manager.
Sourcepub fn declare_dynamic_plugin_by_name<S: Into<String>>(
&mut self,
id: S,
plugin_name: S,
required: bool,
) -> ZResult<&mut dyn DeclaredPlugin<StartArgs, Instance>>
pub fn declare_dynamic_plugin_by_name<S: Into<String>>( &mut self, id: S, plugin_name: S, required: bool, ) -> ZResult<&mut dyn DeclaredPlugin<StartArgs, Instance>>
Add dynamic plugin to the manager by name, automatically prepending the default library prefix
Sourcepub fn declare_dynamic_plugin_by_paths<S: Into<String>, P: AsRef<str> + Debug>(
&mut self,
name: S,
id: S,
paths: &[P],
required: bool,
) -> ZResult<&mut dyn DeclaredPlugin<StartArgs, Instance>>
pub fn declare_dynamic_plugin_by_paths<S: Into<String>, P: AsRef<str> + Debug>( &mut self, name: S, id: S, paths: &[P], required: bool, ) -> ZResult<&mut dyn DeclaredPlugin<StartArgs, Instance>>
Add first available dynamic plugin from the list of paths to the plugin files
Sourcepub fn declared_plugins_iter(
&self,
) -> impl Iterator<Item = &dyn DeclaredPlugin<StartArgs, Instance>> + '_
pub fn declared_plugins_iter( &self, ) -> impl Iterator<Item = &dyn DeclaredPlugin<StartArgs, Instance>> + '_
Lists all plugins
Sourcepub fn declared_plugins_iter_mut(
&mut self,
) -> impl Iterator<Item = &mut dyn DeclaredPlugin<StartArgs, Instance>> + '_
pub fn declared_plugins_iter_mut( &mut self, ) -> impl Iterator<Item = &mut dyn DeclaredPlugin<StartArgs, Instance>> + '_
Lists all plugins mutable
Sourcepub fn loaded_plugins_iter(
&self,
) -> impl Iterator<Item = &dyn LoadedPlugin<StartArgs, Instance>> + '_
pub fn loaded_plugins_iter( &self, ) -> impl Iterator<Item = &dyn LoadedPlugin<StartArgs, Instance>> + '_
Lists the loaded plugins
Sourcepub fn loaded_plugins_iter_mut(
&mut self,
) -> impl Iterator<Item = &mut dyn LoadedPlugin<StartArgs, Instance>> + '_
pub fn loaded_plugins_iter_mut( &mut self, ) -> impl Iterator<Item = &mut dyn LoadedPlugin<StartArgs, Instance>> + '_
Lists the loaded plugins mutable
Sourcepub fn started_plugins_iter(
&self,
) -> impl Iterator<Item = &dyn StartedPlugin<StartArgs, Instance>> + '_
pub fn started_plugins_iter( &self, ) -> impl Iterator<Item = &dyn StartedPlugin<StartArgs, Instance>> + '_
Lists the started plugins
Sourcepub fn started_plugins_iter_mut(
&mut self,
) -> impl Iterator<Item = &mut dyn StartedPlugin<StartArgs, Instance>> + '_
pub fn started_plugins_iter_mut( &mut self, ) -> impl Iterator<Item = &mut dyn StartedPlugin<StartArgs, Instance>> + '_
Lists the started plugins mutable
Sourcepub fn plugin(
&self,
id: &str,
) -> Option<&dyn DeclaredPlugin<StartArgs, Instance>>
pub fn plugin( &self, id: &str, ) -> Option<&dyn DeclaredPlugin<StartArgs, Instance>>
Returns single plugin record by id
Sourcepub fn plugin_mut(
&mut self,
id: &str,
) -> Option<&mut dyn DeclaredPlugin<StartArgs, Instance>>
pub fn plugin_mut( &mut self, id: &str, ) -> Option<&mut dyn DeclaredPlugin<StartArgs, Instance>>
Returns mutable plugin record by id
Sourcepub fn loaded_plugin(
&self,
id: &str,
) -> Option<&dyn LoadedPlugin<StartArgs, Instance>>
pub fn loaded_plugin( &self, id: &str, ) -> Option<&dyn LoadedPlugin<StartArgs, Instance>>
Returns loaded plugin record by id
Sourcepub fn loaded_plugin_mut(
&mut self,
id: &str,
) -> Option<&mut dyn LoadedPlugin<StartArgs, Instance>>
pub fn loaded_plugin_mut( &mut self, id: &str, ) -> Option<&mut dyn LoadedPlugin<StartArgs, Instance>>
Returns mutable loaded plugin record by id
Sourcepub fn started_plugin(
&self,
id: &str,
) -> Option<&dyn StartedPlugin<StartArgs, Instance>>
pub fn started_plugin( &self, id: &str, ) -> Option<&dyn StartedPlugin<StartArgs, Instance>>
Returns started plugin record by id
Sourcepub fn started_plugin_mut(
&mut self,
id: &str,
) -> Option<&mut dyn StartedPlugin<StartArgs, Instance>>
pub fn started_plugin_mut( &mut self, id: &str, ) -> Option<&mut dyn StartedPlugin<StartArgs, Instance>>
Returns mutable started plugin record by id
Trait Implementations§
Source§impl<StartArgs: PluginStartArgs + 'static, Instance: PluginInstance + 'static> PluginControl for PluginsManager<StartArgs, Instance>
impl<StartArgs: PluginStartArgs + 'static, Instance: PluginInstance + 'static> PluginControl for PluginsManager<StartArgs, Instance>
Source§fn plugins_status(&self, names: &keyexpr) -> Vec<PluginStatusRec<'_>>
fn plugins_status(&self, names: &keyexpr) -> Vec<PluginStatusRec<'_>>
_names
key expression. The information is richer than the one returned by report()
: it contains external information about the running plugin, such as its name, path on disk, load status, etc.
Returns an empty list by default.Source§fn report(&self) -> PluginReport
fn report(&self) -> PluginReport
PluginReportLevel::Normal
and the list of messages is empty.
This can be overridden by the plugin implementation if the plugin is able to report its status: no connection to the database, etc.