pub struct Entity { /* private fields */ }Expand description
A lightweight entity identifier with generational indexing.
The generation field prevents use-after-despawn bugs: if an entity is
despawned and its slot reused, the old Entity handle will fail
is_alive checks because the generation won’t match.
Implementations§
Source§impl Entity
impl Entity
Sourcepub fn from_raw(index: u32, generation: u32) -> Self
pub fn from_raw(index: u32, generation: u32) -> Self
Reconstruct an Entity handle from its raw index and generation.
This is intended for the WASM bridge where JS passes back an entity ID
that was previously returned by spawn. The caller is responsible for
providing a valid (index, generation) pair — passing stale or fabricated
values is safe but will cause is_alive / get to return None.
Sourcepub fn generation(self) -> u32
pub fn generation(self) -> u32
Returns the generation portion of this entity ID.
Trait Implementations§
impl Copy for Entity
impl Eq for Entity
impl StructuralPartialEq for Entity
Auto Trait Implementations§
impl Freeze for Entity
impl RefUnwindSafe for Entity
impl Send for Entity
impl Sync for Entity
impl Unpin for Entity
impl UnsafeUnpin for Entity
impl UnwindSafe for Entity
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