pub struct EntityMap { /* private fields */ }
Expand description
A mapping from one set of entities to another.
The API generally follows HashMap
, but each Entity
is returned by value, as they are Copy
.
This is typically used to coordinate data transfer between sets of entities, such as between a scene and the world or over the network.
This is required as Entity
identifiers are opaque; you cannot and do not want to reuse identifiers directly.
Implementations§
source§impl EntityMap
impl EntityMap
sourcepub fn insert(&mut self, from: Entity, to: Entity) -> Option<Entity>
pub fn insert(&mut self, from: Entity, to: Entity) -> Option<Entity>
Inserts an entities pair into the map.
If the map did not have from
present, None
is returned.
If the map did have from
present, the value is updated, and the old value is returned.
sourcepub fn remove(&mut self, entity: Entity) -> Option<Entity>
pub fn remove(&mut self, entity: Entity) -> Option<Entity>
Removes an entity
from the map, returning the mapped value of it if the entity
was previously in the map.
sourcepub fn entry(&mut self, entity: Entity) -> Entry<'_, Entity, Entity>
pub fn entry(&mut self, entity: Entity) -> Entry<'_, Entity, Entity>
Gets the given entity’s corresponding entry in the map for in-place manipulation.
sourcepub fn get(&self, entity: Entity) -> Result<Entity, MapEntitiesError>
pub fn get(&self, entity: Entity) -> Result<Entity, MapEntitiesError>
Returns the corresponding mapped entity.
sourcepub fn keys(&self) -> impl Iterator<Item = Entity> + '_
pub fn keys(&self) -> impl Iterator<Item = Entity> + '_
An iterator visiting all keys in arbitrary order.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for EntityMap
impl Send for EntityMap
impl Sync for EntityMap
impl Unpin for EntityMap
impl UnwindSafe for EntityMap
Blanket Implementations§
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§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.source§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.source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere T: Default,
source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given World