pub struct PluginManager { /* private fields */ }Expand description
Manager for all plugin runtimes and loaded plugins.
Implementations§
Source§impl PluginManager
impl PluginManager
Sourcepub fn new(config: PluginConfig) -> Self
pub fn new(config: PluginConfig) -> Self
Create a new plugin manager with the given configuration.
Sourcepub fn register_runtime(
&mut self,
runtime: Box<dyn PluginRuntime>,
) -> PluginResult<()>
pub fn register_runtime( &mut self, runtime: Box<dyn PluginRuntime>, ) -> PluginResult<()>
Register a plugin runtime.
Sourcepub fn get_runtime(&self, name: &str) -> Option<&dyn PluginRuntime>
pub fn get_runtime(&self, name: &str) -> Option<&dyn PluginRuntime>
Get a runtime by name.
Sourcepub fn get_runtime_mut(
&mut self,
name: &str,
) -> Option<&mut Box<dyn PluginRuntime>>
pub fn get_runtime_mut( &mut self, name: &str, ) -> Option<&mut Box<dyn PluginRuntime>>
Get a mutable runtime by name.
Sourcepub fn init_runtimes(&mut self) -> PluginResult<()>
pub fn init_runtimes(&mut self) -> PluginResult<()>
Initialize all registered runtimes.
Sourcepub async fn discover_plugins(&mut self) -> PluginResult<Vec<LoadedPlugin>>
pub async fn discover_plugins(&mut self) -> PluginResult<Vec<LoadedPlugin>>
Discover and load plugins from the plugin directory.
Sourcepub fn load_plugin(&mut self, path: &Path) -> PluginResult<LoadedPlugin>
pub fn load_plugin(&mut self, path: &Path) -> PluginResult<LoadedPlugin>
Load a single plugin from a path.
Sourcepub fn unload_plugin(&mut self, handle: PluginHandle) -> PluginResult<()>
pub fn unload_plugin(&mut self, handle: PluginHandle) -> PluginResult<()>
Unload a plugin.
Sourcepub async fn dispatch_hook(
&self,
hook: &Hook,
ctx: &HookContext,
) -> Vec<HookResult>
pub async fn dispatch_hook( &self, hook: &Hook, ctx: &HookContext, ) -> Vec<HookResult>
Dispatch a hook to all plugins that implement it.
The overall timeout bounds cooperatively yielding hook futures; worker deadlines and the runtimes’ instruction hooks bound script execution.
Sourcepub fn any_prevent_default(results: &[HookResult]) -> bool
pub fn any_prevent_default(results: &[HookResult]) -> bool
Returns true if any hook result requested that the host’s default action
be prevented. Callers that gate a default action on plugins (navigation,
deletion, …) can use this on the dispatch_hook
results.
Sourcepub fn get_plugin(&self, handle: PluginHandle) -> Option<&LoadedPlugin>
pub fn get_plugin(&self, handle: PluginHandle) -> Option<&LoadedPlugin>
Get a loaded plugin by handle.
Sourcepub fn plugins_of_kind(
&self,
kind: PluginKind,
) -> impl Iterator<Item = &LoadedPlugin>
pub fn plugins_of_kind( &self, kind: PluginKind, ) -> impl Iterator<Item = &LoadedPlugin>
Get plugins of a specific kind.
Sourcepub fn shutdown(&mut self) -> PluginResult<()>
pub fn shutdown(&mut self) -> PluginResult<()>
Shutdown all runtimes.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PluginManager
impl !UnwindSafe for PluginManager
impl Freeze for PluginManager
impl Send for PluginManager
impl Sync for PluginManager
impl Unpin for PluginManager
impl UnsafeUnpin for PluginManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more