pub struct Entity {
index: u32,
generation: u32,
name: &'static str,
}Expand description
A handle to an entity.
The handle is a plain value: it stays valid across world mutations as long as the entity lives, and resolves to nothing once the entity is despawned.
It also carries a name, which Debug prints. A name is given where the
entity is made: a crate::bundle! names it after its own source position,
crate::DynamicBundle::named and crate::ScopeMut::spawn_named after
the string the caller passed, and crate::World::reserve_entity at the
reservation. Two handles to one entity can carry different names and still be
equal, because a handle restored from Entity::to_bits has no name to
restore; crate::Scope::entity_name reads the one the row stores.
Fields§
§index: u32§generation: u32§name: &'static strImplementations§
Source§impl Entity
impl Entity
Sourcepub const fn from_raw(index: u32, generation: u32) -> Self
pub const fn from_raw(index: u32, generation: u32) -> Self
Build a handle from raw parts.
The handle only refers to an entity if it was produced by the same world, so this is for restoring a handle that came from that world (a save file, for example).
Sourcepub const fn name(self) -> &'static str
pub const fn name(self) -> &'static str
The name part, empty when the handle was restored rather than spawned.
Sourcepub const fn generation(self) -> u32
pub const fn generation(self) -> u32
The generation part.
Sourcepub const fn to_bits(self) -> u64
pub const fn to_bits(self) -> u64
The two parts as one value, generation high.
This is not the order Ord uses: the comparison is by index first,
then generation, which is what makes entities spawned together sort
together.
Sourcepub const fn from_bits(bits: u64) -> Self
pub const fn from_bits(bits: u64) -> Self
The handle Entity::to_bits produced.
The handle only refers to an entity if it was produced by the same world, so this is for restoring a handle that came from that world. The restored handle carries no name.
Trait Implementations§
impl Copy for Entity
Source§impl Debug for Entity
Prints the name and the bits the handle travels as, and not the index and
generation they are made of: those are the allocator’s business, while the
bits are the only part a caller holds when the handle came over a wire.
impl Debug for Entity
Prints the name and the bits the handle travels as, and not the index and generation they are made of: those are the allocator’s business, while the bits are the only part a caller holds when the handle came over a wire.
impl Eq for Entity
Source§impl From<&Entity> for EntityProxy
Available on crate feature reflect only.
impl From<&Entity> for EntityProxy
reflect only.Source§impl From<EntityProxy> for Entity
Available on crate feature reflect only.
impl From<EntityProxy> for Entity
reflect only.Source§fn from(proxy: EntityProxy) -> Self
fn from(proxy: EntityProxy) -> Self
Source§impl Ord for Entity
impl Ord for Entity
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Entity
impl PartialOrd for Entity
Source§impl Query for Entity
Asks for the entity itself.
impl Query for Entity
Asks for the entity itself.
It is an item like any other, so it can be written first, last, or on its
own: a query over Entity alone yields every entity the scope sees.
Auto Trait Implementations§
impl Forget for Entity
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> Component for Twhere
T: 'static,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.