pub struct RequiredComponentsRegistrator<'a, 'w> { /* private fields */ }Expand description
This is a safe handle around ComponentsRegistrator and RequiredComponents to register required components.
Implementations§
Source§impl<'a, 'w> RequiredComponentsRegistrator<'a, 'w>
impl<'a, 'w> RequiredComponentsRegistrator<'a, 'w>
Sourcepub fn register_required<C: Component>(&mut self, constructor: fn() -> C)
pub fn register_required<C: Component>(&mut self, constructor: fn() -> C)
Registers the Component C as an explicitly required component.
If the component was not already registered as an explicit required component then it is added as one, potentially overriding the constructor of a inherited required component, otherwise panics.
Sourcepub unsafe fn register_required_by_id<C: Component>(
&mut self,
component_id: ComponentId,
constructor: fn() -> C,
)
pub unsafe fn register_required_by_id<C: Component>( &mut self, component_id: ComponentId, constructor: fn() -> C, )
Registers the Component with the given component_id ID as an explicitly required component.
If the component was not already registered as an explicit required component then it is added as one, potentially overriding the constructor of a inherited required component, otherwise panics.
§Safety
component_id must be a valid ComponentId for C in the Components instance of self.
Sourcepub unsafe fn register_required_dynamic_with(
&mut self,
component_id: ComponentId,
constructor: impl FnOnce() -> RequiredComponentConstructor,
)
pub unsafe fn register_required_dynamic_with( &mut self, component_id: ComponentId, constructor: impl FnOnce() -> RequiredComponentConstructor, )
Registers the Component with the given component_id ID as an explicitly required component.
If the component was not already registered as an explicit required component then it is added as one, potentially overriding the constructor of a inherited required component, otherwise panics.
§Safety
component_idmust be valid in theComponentsinstance ofself;constructormust return aRequiredComponentConstructorthat constructs a valid instance for the component with IDcomponent_id.