Skip to main content

PluginRegistry

Struct PluginRegistry 

Source
pub struct PluginRegistry { /* private fields */ }
Expand description

Keyed collection of compiled plugins. Lookup is by id; iteration preserves discovery order. Non-fatal load errors (compile failure, unknown dep, id collision) live alongside the compiled plugins so post-load consumers (e.g. linesmith doctor) can query them at any point without re-running discovery.

Implementations§

Source§

impl PluginRegistry

Source

pub fn load( config_dirs: &[PathBuf], engine: &Engine, built_in_ids: &[&str], ) -> Self

Discover, compile, and register every plugin across config_dirs plus the default XDG segments directory. built_in_ids is the set of reserved ids that plugins cannot shadow (plugins attempting to register one of these names are rejected as IdCollision).

Non-fatal load errors are collected on the returned registry; query them via Self::load_errors. A missing or unreadable directory is not an error — the discovery layer silently skips it.

Source

pub fn load_with_xdg( config_dirs: &[PathBuf], xdg_dir: Option<&Path>, engine: &Engine, built_in_ids: &[&str], ) -> Self

Explicit-XDG variant of Self::load. Passes xdg_dir through to the discovery scan rather than reading XDG_CONFIG_HOME from the process env. Use None to skip the XDG fallback entirely — driver paths pass an env-derived PathBuf so test harnesses with a hermetic env snapshot don’t pick up the developer’s real ~/.config/linesmith/segments/.

Source

pub fn load_errors(&self) -> &[PluginError]

Non-fatal errors from the most recent load. Includes compile failures, malformed @data_deps headers, unknown dep names, and id collisions (with built-ins or other plugins). Returns an empty slice when every plugin loaded cleanly.

Source

pub fn get(&self, id: &str) -> Option<&CompiledPlugin>

Look up a compiled plugin by its const ID value.

Source

pub fn iter(&self) -> impl Iterator<Item = &CompiledPlugin>

Iterate every compiled plugin in discovery order.

Source

pub fn len(&self) -> usize

Total number of compiled plugins.

Source

pub fn is_empty(&self) -> bool

true when no plugins were discovered or compiled.

Source

pub fn into_plugins(self) -> Vec<CompiledPlugin>

Consume the registry, yielding every compiled plugin by value. The segment builder pulls plugins out by id this way to move each CompiledPlugin into a consumer-side adapter.

Auto Trait Implementations§

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