Struct bevy::ecs::component::ComponentId
pub struct ComponentId(/* private fields */);
Expand description
A value which uniquely identifies the type of a Component
within a
World
.
Each time a new Component
type is registered within a World
using
World::init_component
or
World::init_component_with_descriptor
,
a corresponding ComponentId
is created to track it.
While the distinction between ComponentId
and TypeId
may seem superficial, breaking them
into two separate but related concepts allows components to exist outside of Rust’s type system.
Each Rust type registered as a Component
will have a corresponding ComponentId
, but additional
ComponentId
s may exist in a World
to track components which cannot be
represented as Rust types for scripting or other advanced use-cases.
A ComponentId
is tightly coupled to its parent World
. Attempting to use a ComponentId
from
one World
to access the metadata of a Component
in a different World
is undefined behavior
and must not be attempted.
Given a type T
which implements Component
, the ComponentId
for T
can be retrieved
from a World
using World::component_id()
or via Components::component_id()
. Access
to the ComponentId
for a Resource
is available via Components::resource_id()
.
Implementations§
§impl ComponentId
impl ComponentId
pub const fn new(index: usize) -> ComponentId
pub const fn new(index: usize) -> ComponentId
Creates a new ComponentId
.
The index
is a unique value associated with each type of component in a given world.
Usually, this value is taken from a counter incremented for each type of component registered with the world.
Trait Implementations§
§impl Clone for ComponentId
impl Clone for ComponentId
§fn clone(&self) -> ComponentId
fn clone(&self) -> ComponentId
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for ComponentId
impl Debug for ComponentId
§impl<T> From<ComponentIdFor<'_, T>> for ComponentIdwhere
T: Component,
impl<T> From<ComponentIdFor<'_, T>> for ComponentIdwhere T: Component,
§fn from(to_component_id: ComponentIdFor<'_, T>) -> ComponentId
fn from(to_component_id: ComponentIdFor<'_, T>) -> ComponentId
§impl Hash for ComponentId
impl Hash for ComponentId
§impl Ord for ComponentId
impl Ord for ComponentId
§impl PartialEq for ComponentId
impl PartialEq for ComponentId
§fn eq(&self, other: &ComponentId) -> bool
fn eq(&self, other: &ComponentId) -> bool
self
and other
values to be equal, and is used
by ==
.§impl PartialOrd for ComponentId
impl PartialOrd for ComponentId
§fn partial_cmp(&self, other: &ComponentId) -> Option<Ordering>
fn partial_cmp(&self, other: &ComponentId) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more§impl SparseSetIndex for ComponentId
impl SparseSetIndex for ComponentId
§fn sparse_set_index(&self) -> usize
fn sparse_set_index(&self) -> usize
§fn get_sparse_set_index(value: usize) -> ComponentId
fn get_sparse_set_index(value: usize) -> ComponentId
impl Copy for ComponentId
impl Eq for ComponentId
impl StructuralEq for ComponentId
impl StructuralPartialEq for ComponentId
Auto Trait Implementations§
impl RefUnwindSafe for ComponentId
impl Send for ComponentId
impl Sync for ComponentId
impl Unpin for ComponentId
impl UnwindSafe for ComponentId
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§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
.§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
.§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.§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.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.