pub struct RequiredComponents(/* private fields */);
Expand description
The collection of metadata for components that are required for a given component.
For more information, see the “Required Components” section of Component
.
Implementations§
Source§impl RequiredComponents
impl RequiredComponents
Sourcepub unsafe fn register_dynamic(
&mut self,
component_id: ComponentId,
constructor: RequiredComponentConstructor,
inheritance_depth: u16,
)
pub unsafe fn register_dynamic( &mut self, component_id: ComponentId, constructor: RequiredComponentConstructor, inheritance_depth: u16, )
Registers a required component.
If the component is already registered, it will be overwritten if the given inheritance depth is smaller than the depth of the existing registration. Otherwise, the new registration will be ignored.
§Safety
component_id
must match the type initialized by constructor
.
constructor
must initialize a component for component_id
in such a way that
matches the storage type of the component. It must only use the given table_row
or Entity
to
initialize the storage for component_id
corresponding to the given entity.
Sourcepub fn register<C: Component>(
&mut self,
components: &mut Components,
storages: &mut Storages,
constructor: fn() -> C,
inheritance_depth: u16,
)
pub fn register<C: Component>( &mut self, components: &mut Components, storages: &mut Storages, constructor: fn() -> C, inheritance_depth: u16, )
Registers a required component.
If the component is already registered, it will be overwritten if the given inheritance depth is smaller than the depth of the existing registration. Otherwise, the new registration will be ignored.
Sourcepub fn register_by_id<C: Component>(
&mut self,
component_id: ComponentId,
constructor: fn() -> C,
inheritance_depth: u16,
)
pub fn register_by_id<C: Component>( &mut self, component_id: ComponentId, constructor: fn() -> C, inheritance_depth: u16, )
Registers the Component
with the given ID as required if it exists.
If the component is already registered, it will be overwritten if the given inheritance depth is smaller than the depth of the existing registration. Otherwise, the new registration will be ignored.
Sourcepub fn iter_ids(&self) -> impl Iterator<Item = ComponentId> + '_
pub fn iter_ids(&self) -> impl Iterator<Item = ComponentId> + '_
Iterates the ids of all required components. This includes recursive required components.
Trait Implementations§
Source§impl Clone for RequiredComponents
impl Clone for RequiredComponents
Source§fn clone(&self) -> RequiredComponents
fn clone(&self) -> RequiredComponents
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for RequiredComponents
impl Debug for RequiredComponents
Source§impl Default for RequiredComponents
impl Default for RequiredComponents
Source§fn default() -> RequiredComponents
fn default() -> RequiredComponents
Auto Trait Implementations§
impl Freeze for RequiredComponents
impl !RefUnwindSafe for RequiredComponents
impl !Send for RequiredComponents
impl !Sync for RequiredComponents
impl Unpin for RequiredComponents
impl !UnwindSafe for RequiredComponents
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self
using default()
.