pub struct Registry<T> { /* private fields */ }Expand description
A thread-safe registry for named components.
Provides concurrent read access with exclusive write access, suitable for storing configuration-driven components that are read frequently but updated rarely (e.g., during config reload).
Implementations§
Source§impl<T> Registry<T>
impl<T> Registry<T>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a registry with pre-allocated capacity.
Sourcepub fn from_map(map: HashMap<String, Arc<T>>) -> Self
pub fn from_map(map: HashMap<String, Arc<T>>) -> Self
Create a registry from an existing HashMap.
Sourcepub async fn insert(
&self,
id: impl Into<String>,
item: Arc<T>,
) -> Option<Arc<T>>
pub async fn insert( &self, id: impl Into<String>, item: Arc<T>, ) -> Option<Arc<T>>
Insert a component, returning the previous value if any.
Sourcepub async fn replace(
&self,
new_items: HashMap<String, Arc<T>>,
) -> HashMap<String, Arc<T>>
pub async fn replace( &self, new_items: HashMap<String, Arc<T>>, ) -> HashMap<String, Arc<T>>
Replace all items atomically, returning the old map.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Registry<T>
impl<T> !RefUnwindSafe for Registry<T>
impl<T> Send for Registry<T>
impl<T> Sync for Registry<T>
impl<T> Unpin for Registry<T>
impl<T> !UnwindSafe for Registry<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more