pub struct ComponentRegistry(/* private fields */);Expand description
Store component factories. This is how components are created.
Implementations§
Source§impl ComponentRegistry
impl ComponentRegistry
pub fn new() -> Self
Sourcepub fn add_component<S: State>(
&mut self,
id: ComponentBlueprintId,
component: impl Component + 'static,
state: S,
)
pub fn add_component<S: State>( &mut self, id: ComponentBlueprintId, component: impl Component + 'static, state: S, )
Both add_component and add_prototype are using Slab::insert_at.
This is fine as the component ids are generated at the same time.
pub fn add_prototype<FC, FS, C, S>( &mut self, id: ComponentBlueprintId, proto: FC, state: FS, )
Sourcepub fn return_component(
&mut self,
id: ComponentBlueprintId,
current_component: Box<dyn AnyComponent>,
current_state: Box<dyn State>,
)
pub fn return_component( &mut self, id: ComponentBlueprintId, current_component: Box<dyn AnyComponent>, current_state: Box<dyn State>, )
Return a component back to the registry.
§Panics
Panics if the component entry doesn’t exist or if the entry is for a prototype.
Auto Trait Implementations§
impl Freeze for ComponentRegistry
impl !RefUnwindSafe for ComponentRegistry
impl !Send for ComponentRegistry
impl !Sync for ComponentRegistry
impl Unpin for ComponentRegistry
impl UnsafeUnpin for ComponentRegistry
impl !UnwindSafe 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