pub struct PluginRegistry<R: PluginRuntime> { /* private fields */ }Expand description
Holds all loaded plugins keyed by PluginId.
Thread-safe via RwLock — concurrent reads are cheap; writes (load /
unload) take an exclusive lock only while mutating the map.
Implementations§
Source§impl<R: PluginRuntime> PluginRegistry<R>
impl<R: PluginRuntime> PluginRegistry<R>
Sourcepub async fn load(
&self,
manifest: PluginManifest,
plugin: Arc<dyn HomeCorePlugin>,
hc: HomeCore,
) -> Result<PluginId, PluginError>
pub async fn load( &self, manifest: PluginManifest, plugin: Arc<dyn HomeCorePlugin>, hc: HomeCore, ) -> Result<PluginId, PluginError>
Load a plugin, call its setup hook, and insert it into the registry.
Returns PluginError::AlreadyLoaded if a plugin with the same ID is
already registered.
Sourcepub async fn unload(&self, id: &PluginId) -> Result<(), PluginError>
pub async fn unload(&self, id: &PluginId) -> Result<(), PluginError>
Unload a plugin by ID, calling its unload hook first.
Returns PluginError::NotFound if the plugin was not loaded.
Sourcepub async fn list(&self) -> Vec<(PluginId, String)>
pub async fn list(&self) -> Vec<(PluginId, String)>
Return a snapshot of currently loaded plugin IDs and their manifest domains.
Sourcepub async fn contains(&self, id: &PluginId) -> bool
pub async fn contains(&self, id: &PluginId) -> bool
Return true if a plugin with this ID is loaded.
Sourcepub async fn state_changed(
&self,
event: &StateChangedEventJson,
) -> Vec<(PluginId, PluginError)>
pub async fn state_changed( &self, event: &StateChangedEventJson, ) -> Vec<(PluginId, PluginError)>
Dispatch a state change in stable plugin-domain order.
Sourcepub async fn shutdown(&self) -> Vec<(PluginId, PluginError)>
pub async fn shutdown(&self) -> Vec<(PluginId, PluginError)>
Tear down all plugins in reverse domain order. Failures are collected while remaining plugins still receive teardown.
Auto Trait Implementations§
impl<R> !Freeze for PluginRegistry<R>
impl<R> !RefUnwindSafe for PluginRegistry<R>
impl<R> !UnwindSafe for PluginRegistry<R>
impl<R> Send for PluginRegistry<R>
impl<R> Sync for PluginRegistry<R>
impl<R> Unpin for PluginRegistry<R>where
R: Unpin,
impl<R> UnsafeUnpin for PluginRegistry<R>where
R: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more