pub struct ComponentRegistry { /* private fields */ }Expand description
Registry for storing components with runtime borrow tracking.
The registry tracks which components are currently mutably borrowed to prevent multiple simultaneous mutable borrows (which would be undefined behavior).
Implementations§
Source§impl ComponentRegistry
impl ComponentRegistry
pub fn new() -> Self
pub fn insert(&self, id: Ustr, component: Rc<UnsafeCell<dyn Component>>)
pub fn get(&self, id: &Ustr) -> Option<Rc<UnsafeCell<dyn Component>>>
Sourcepub fn remove(&self, id: &Ustr) -> Option<Rc<UnsafeCell<dyn Component>>>
pub fn remove(&self, id: &Ustr) -> Option<Rc<UnsafeCell<dyn Component>>>
Removes the component with id, returning it when it was registered.
Sourcepub fn is_borrowed(&self, id: &Ustr) -> bool
pub fn is_borrowed(&self, id: &Ustr) -> bool
Checks if a component is currently borrowed.
Trait Implementations§
Source§impl Debug for ComponentRegistry
impl Debug for ComponentRegistry
Auto Trait Implementations§
impl !Freeze for ComponentRegistry
impl !RefUnwindSafe for ComponentRegistry
impl !Send for ComponentRegistry
impl !Sync for ComponentRegistry
impl !UnwindSafe for ComponentRegistry
impl Unpin for ComponentRegistry
impl UnsafeUnpin for ComponentRegistry
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