pub struct ComponentId(/* private fields */);
Expand description
Lightweight identifier for a component type.
component identifiers are implemented using an index and a generation count. The generation count ensures that IDs from removed components are not reused by new components.
A component identifier is only meaningful in the World
it was created
from. Attempting to use a component ID in a different world will have
unexpected results.
Implementations§
Source§impl ComponentId
impl ComponentId
Sourcepub const NULL: ComponentId
pub const NULL: ComponentId
The component ID which never identifies a live component. This is the
default value for ComponentId
.
Sourcepub const fn new(index: u32, generation: u32) -> Option<ComponentId>
pub const fn new(index: u32, generation: u32) -> Option<ComponentId>
Creates a new component ID from an index and generation count. Returns
None
if a valid ID is not formed.
Sourcepub const fn index(self) -> ComponentIdx
pub const fn index(self) -> ComponentIdx
Returns the index of this ID.
Sourcepub const fn generation(self) -> u32
pub const fn generation(self) -> u32
Returns the generation count of this ID.
Trait Implementations§
Source§impl Clone for ComponentId
impl Clone for ComponentId
Source§fn clone(&self) -> ComponentId
fn clone(&self) -> ComponentId
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ComponentId
impl Debug for ComponentId
Source§impl Default for ComponentId
impl Default for ComponentId
Source§fn default() -> ComponentId
fn default() -> ComponentId
Returns the “default value” for a type. Read more
Source§impl Hash for ComponentId
impl Hash for ComponentId
Source§impl Ord for ComponentId
impl Ord for ComponentId
Source§fn cmp(&self, other: &ComponentId) -> Ordering
fn cmp(&self, other: &ComponentId) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for ComponentId
impl PartialEq for ComponentId
Source§impl PartialOrd for ComponentId
impl PartialOrd for ComponentId
impl Copy for ComponentId
impl Eq for ComponentId
impl StructuralPartialEq for ComponentId
Auto Trait Implementations§
impl Freeze for ComponentId
impl RefUnwindSafe for ComponentId
impl Send for ComponentId
impl Sync for ComponentId
impl Unpin for ComponentId
impl UnwindSafe for ComponentId
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.