pub struct Registry<T> { /* private fields */ }Expand description
A strict, capacity-limited registry that separates Cold Path (registration) from Hot Path (access) to ensure consistent performance.
Implementations§
Source§impl<T> Registry<T>
impl<T> Registry<T>
Sourcepub fn new(capacity: usize) -> Result<Self, RegistryError>
pub fn new(capacity: usize) -> Result<Self, RegistryError>
Creates a new registry with a fixed capacity. Pre-allocates all necessary memory to avoid runtime allocations.
Sourcepub fn register(
&mut self,
name: impl Into<String>,
item: T,
) -> Result<HandlerId<T>, RegistryError>
pub fn register( &mut self, name: impl Into<String>, item: T, ) -> Result<HandlerId<T>, RegistryError>
[Cold Path] Registers an item with a string ID. Fails if capacity is exceeded or name already exists.
Sourcepub fn get(&self, id: HandlerId<T>) -> Option<&T>
pub fn get(&self, id: HandlerId<T>) -> Option<&T>
[Hot Path] Access item by ID (No allocation, O(1))
Sourcepub fn get_mut(&mut self, id: HandlerId<T>) -> Option<&mut T>
pub fn get_mut(&mut self, id: HandlerId<T>) -> Option<&mut T>
[Hot Path] Mutable access item by ID (No allocation, O(1))
Sourcepub fn lookup(&self, name: &str) -> Option<HandlerId<T>>
pub fn lookup(&self, name: &str) -> Option<HandlerId<T>>
[Cold Path] Look up a handler ID by name
Sourcepub fn remove(&mut self, id: HandlerId<T>) -> Option<T>
pub fn remove(&mut self, id: HandlerId<T>) -> Option<T>
[Cold Path] Remove an item by ID. Updates generation to invalidate old handles and cleans up name map.
Auto Trait Implementations§
impl<T> Freeze for Registry<T>
impl<T> RefUnwindSafe for Registry<T>where
T: RefUnwindSafe,
impl<T> Send for Registry<T>where
T: Send,
impl<T> Sync for Registry<T>where
T: Sync,
impl<T> Unpin for Registry<T>where
T: Unpin,
impl<T> UnwindSafe for Registry<T>where
T: UnwindSafe,
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