Skip to main content

PickerRegistry

Struct PickerRegistry 

Source
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

Source

pub fn new() -> Self

Source

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.

Source

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.

Source

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

Source

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

Source

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.

Source

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

Source

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.

Source

pub fn ids(&self) -> impl Iterator<Item = &str> + '_

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl Clone for PickerRegistry

Source§

fn clone(&self) -> PickerRegistry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PickerRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PickerRegistry

Source§

fn default() -> PickerRegistry

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more