Skip to main content

PluginRegistry

Struct PluginRegistry 

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

Source

pub fn new(runtime: R) -> Self

Create an empty registry backed by runtime.

Source

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.

Source

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.

Source

pub async fn list(&self) -> Vec<(PluginId, String)>

Return a snapshot of currently loaded plugin IDs and their manifest domains.

Source

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

Return true if a plugin with this ID is loaded.

Source

pub async fn state_changed( &self, event: &StateChangedEventJson, ) -> Vec<(PluginId, PluginError)>

Dispatch a state change in stable plugin-domain order.

Source

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

Source§

type Output = T

Should always be Self
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.