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, RandomState>
pub fn entry( &mut self, entity: Entity, ) -> Entry<'_, Entity, Entity, RandomState>
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 Freeze for EntityMap
impl RefUnwindSafe for EntityMap
impl Send for EntityMap
impl Sync for EntityMap
impl Unpin for EntityMap
impl UnsafeUnpin for EntityMap
impl UnwindSafe for EntityMap
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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> DowncastSync for T
impl<T> DowncastSync for T
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