pub struct EntityId {
pub index: u32,
pub generation: u32,
}Expand description
A unique identifier for an entity in the world.
It combines an index with a generation count to solve the “ABA problem”.
When an entity is despawned, its index can be recycled for a new entity,
but the generation is incremented. This ensures that old EntityId handles
pointing to a recycled index become invalid and cannot accidentally affect
the new entity.
Fields§
§index: u32The index of the entity’s metadata in the central Vec<EntityMetadata>.
generation: u32A generation counter that is incremented each time the index is recycled.
Trait Implementations§
Source§impl<'__de, __Context> BorrowDecode<'__de, __Context> for EntityId
impl<'__de, __Context> BorrowDecode<'__de, __Context> for EntityId
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl<'de> Deserialize<'de> for EntityId
impl<'de> Deserialize<'de> for EntityId
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for EntityId
impl Eq for EntityId
impl StructuralPartialEq for EntityId
Auto Trait Implementations§
impl Freeze for EntityId
impl RefUnwindSafe for EntityId
impl Send for EntityId
impl Sync for EntityId
impl Unpin for EntityId
impl UnwindSafe for EntityId
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