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
impl PluginRegistry
Sourcepub fn load(
config_dirs: &[PathBuf],
engine: &Engine,
built_in_ids: &[&str],
) -> Self
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.
Sourcepub fn load_with_xdg(
config_dirs: &[PathBuf],
xdg_dir: Option<&Path>,
engine: &Engine,
built_in_ids: &[&str],
) -> Self
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/.
Sourcepub fn load_errors(&self) -> &[PluginError]
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.
Sourcepub fn get(&self, id: &str) -> Option<&CompiledPlugin>
pub fn get(&self, id: &str) -> Option<&CompiledPlugin>
Look up a compiled plugin by its const ID value.
Sourcepub fn iter(&self) -> impl Iterator<Item = &CompiledPlugin>
pub fn iter(&self) -> impl Iterator<Item = &CompiledPlugin>
Iterate every compiled plugin in discovery order.
Sourcepub fn into_plugins(self) -> Vec<CompiledPlugin>
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.