pub struct Registry<T: Registrable> { /* private fields */ }Expand description
A generic, owned registry mapping string keys to &'static T references.
Registries are immutable after construction — no Mutex needed.
Use auto_discover() to populate from inventory, or new() + register()
for manual construction (useful in tests).
Implementations§
Source§impl<T: Registrable> Registry<T>
impl<T: Registrable> Registry<T>
Sourcepub fn auto_discover() -> Selfwhere
T: Collect,
pub fn auto_discover() -> Selfwhere
T: Collect,
Populate from all inventory::submit!-ed items of type T.
Sourcepub fn register(&mut self, item: &'static T)
pub fn register(&mut self, item: &'static T)
Insert a descriptor. If a descriptor with the same key already exists, it is replaced (last-write-wins).
Sourcepub fn get(&self, key: &str) -> Option<&'static T>
pub fn get(&self, key: &str) -> Option<&'static T>
Look up an item by registry key.
Sourcepub fn iter(&self) -> impl Iterator<Item = &'static T> + '_
pub fn iter(&self) -> impl Iterator<Item = &'static T> + '_
Iterates over all registered descriptors in arbitrary order.
Trait Implementations§
Source§impl<T: Registrable> Clone for Registry<T>
impl<T: Registrable> Clone for Registry<T>
Source§impl<T: Registrable> Debug for Registry<T>
impl<T: Registrable> Debug for Registry<T>
Auto Trait Implementations§
impl<T> Freeze for Registry<T>
impl<T> RefUnwindSafe for Registry<T>where
T: RefUnwindSafe,
impl<T> Send for Registry<T>
impl<T> Sync for Registry<T>
impl<T> Unpin for Registry<T>
impl<T> UnsafeUnpin for Registry<T>
impl<T> UnwindSafe for Registry<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more