Struct PluginsManager

Source
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>

Source

pub fn dynamic<S: Into<String>>( loader: LibLoader, default_lib_prefix: S, ) -> Self

Constructs a new plugin manager with dynamic library loading enabled.

Source

pub fn static_plugins_only() -> Self

Constructs a new plugin manager with dynamic library loading disabled.

Source

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.

Source

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

Source

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

Source

pub fn declared_plugins_iter( &self, ) -> impl Iterator<Item = &dyn DeclaredPlugin<StartArgs, Instance>> + '_

Lists all plugins

Source

pub fn declared_plugins_iter_mut( &mut self, ) -> impl Iterator<Item = &mut dyn DeclaredPlugin<StartArgs, Instance>> + '_

Lists all plugins mutable

Source

pub fn loaded_plugins_iter( &self, ) -> impl Iterator<Item = &dyn LoadedPlugin<StartArgs, Instance>> + '_

Lists the loaded plugins

Source

pub fn loaded_plugins_iter_mut( &mut self, ) -> impl Iterator<Item = &mut dyn LoadedPlugin<StartArgs, Instance>> + '_

Lists the loaded plugins mutable

Source

pub fn started_plugins_iter( &self, ) -> impl Iterator<Item = &dyn StartedPlugin<StartArgs, Instance>> + '_

Lists the started plugins

Source

pub fn started_plugins_iter_mut( &mut self, ) -> impl Iterator<Item = &mut dyn StartedPlugin<StartArgs, Instance>> + '_

Lists the started plugins mutable

Source

pub fn plugin( &self, id: &str, ) -> Option<&dyn DeclaredPlugin<StartArgs, Instance>>

Returns single plugin record by id

Source

pub fn plugin_mut( &mut self, id: &str, ) -> Option<&mut dyn DeclaredPlugin<StartArgs, Instance>>

Returns mutable plugin record by id

Source

pub fn loaded_plugin( &self, id: &str, ) -> Option<&dyn LoadedPlugin<StartArgs, Instance>>

Returns loaded plugin record by id

Source

pub fn loaded_plugin_mut( &mut self, id: &str, ) -> Option<&mut dyn LoadedPlugin<StartArgs, Instance>>

Returns mutable loaded plugin record by id

Source

pub fn started_plugin( &self, id: &str, ) -> Option<&dyn StartedPlugin<StartArgs, Instance>>

Returns started plugin record by id

Source

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>

Source§

fn plugins_status(&self, names: &keyexpr) -> Vec<PluginStatusRec<'_>>

Collects information of sub-plugins matching the _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

Returns the current state of the running plugin. By default, the state is 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.

Auto Trait Implementations§

§

impl<StartArgs, Instance> Freeze for PluginsManager<StartArgs, Instance>

§

impl<StartArgs, Instance> !RefUnwindSafe for PluginsManager<StartArgs, Instance>

§

impl<StartArgs, Instance> Send for PluginsManager<StartArgs, Instance>

§

impl<StartArgs, Instance> Sync for PluginsManager<StartArgs, Instance>

§

impl<StartArgs, Instance> Unpin for PluginsManager<StartArgs, Instance>

§

impl<StartArgs, Instance> !UnwindSafe for PluginsManager<StartArgs, Instance>

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> AsNode<T> for T

Source§

fn as_node(&self) -> &T

Source§

impl<T> AsNodeMut<T> for T

Source§

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

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