pub struct PickerRegistry { /* private fields */ }Expand description
Registry of every picker source the :picker <id> ex-command
can dispatch to. Populated at boot by each feature crate’s
register_picker_sources entry point.
Re-registering an id overwrites the previous entry — last
writer wins. In practice each id is registered exactly once
at boot; the overwrite semantics make tests trivial to write
(register twice with different specs to assert the second
wins).
Clone so the host can hold the registry behind an Arc<ArcSwap<_>> and
register plugin sources at runtime by copy-on-write RCU (clone → mutate →
store) — the same wait-free-read / rare-write idiom the snippet registry
uses. Reads stay lock-free; a plugin load / unload swaps a fresh registry
in. Cloning is cheap: the sources map holds &'static str keys and
Arc-shared generators.
Implementations§
Source§impl PickerRegistry
impl PickerRegistry
pub fn new() -> Self
Sourcepub fn register(&mut self, spec: PickerSourceSpec)
pub fn register(&mut self, spec: PickerSourceSpec)
Register a metadata-only entry. Used for sources whose
imperative App-side open_*_picker method still drives
dispatch (slice 12 path). Migrates to
Self::register_generator when the source’s
PickerSourceGenerator impl lands.
Sourcepub fn register_generator(&mut self, generator: Arc<dyn PickerSourceGenerator>)
pub fn register_generator(&mut self, generator: Arc<dyn PickerSourceGenerator>)
Register a source with both metadata and a generator
trait object. The spec is read from generator.spec()
so callers don’t repeat themselves. Canonical path for
fully trait-driven sources.
Sourcepub fn unregister(&mut self, id: &str) -> bool
pub fn unregister(&mut self, id: &str) -> bool
Remove a registered source by its id, the teardown seam for a plugin
reload / unload (PH7.12b). The registry keys on spec.id and carries no
plugin-id provenance, so removal is by id — the host’s teardown bundle
records the id it registered and drives this. Idempotent: false if no
source was registered under id (a second unload, or a never-registered
id). Without it a reload would leave the previous generator’s dead entry
behind (calls fail PluginGone) and the interned id string keeps
leaking across reloads (audit F6, freed by the per-plugin pool in
PH7.12b.2).
pub fn get(&self, id: &str) -> Option<&PickerSourceSpec>
Sourcepub fn entry(&self, id: &str) -> Option<&RegistryEntry>
pub fn entry(&self, id: &str) -> Option<&RegistryEntry>
Borrow the full registry entry (metadata + generator slot). Used by the dispatcher to fetch both pieces at once during the migration window.
Sourcepub fn generator(&self, id: &str) -> Option<&Arc<dyn PickerSourceGenerator>>
pub fn generator(&self, id: &str) -> Option<&Arc<dyn PickerSourceGenerator>>
Look up the registered generator for a source id.
None if the id isn’t registered, or if it’s a
metadata-only entry (slice 12 / pre-migration source).
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &PickerSourceSpec)> + '_
pub fn iter(&self) -> impl Iterator<Item = (&str, &PickerSourceSpec)> + '_
Walk every registered source in id-sorted order.
Deterministic for tab-completion and :describe-picker
listings; tests can rely on the order.
pub fn ids(&self) -> impl Iterator<Item = &str> + '_
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Clone for PickerRegistry
impl Clone for PickerRegistry
Source§fn clone(&self) -> PickerRegistry
fn clone(&self) -> PickerRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more