Skip to main content

GlobalEntityMap

Struct GlobalEntityMap 

Source
pub struct GlobalEntityMap<E: Copy + Eq + Hash + Send + Sync> { /* private fields */ }
Expand description

Bidirectional map between world-local entities and their stable GlobalEntity identifiers.

Implementations§

Source§

impl<E: Copy + Eq + Hash + Send + Sync> GlobalEntityMap<E>

Source

pub fn new() -> Self

Creates an empty map with no entity registrations.

Source

pub fn entity_count(&self) -> usize

Returns the number of world entities currently registered in the map.

Trait Implementations§

Source§

impl<E: Copy + Eq + Hash + Send + Sync> Default for GlobalEntityMap<E>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<E: Copy + Eq + Hash + Send + Sync> EntityAndGlobalEntityConverter<E> for GlobalEntityMap<E>

Source§

fn global_entity_to_entity( &self, global_entity: &GlobalEntity, ) -> Result<E, EntityDoesNotExistError>

Resolves global_entity to the corresponding world-local entity E, or returns an error if not found.
Source§

fn entity_to_global_entity( &self, world_entity: &E, ) -> Result<GlobalEntity, EntityDoesNotExistError>

Resolves a world-local entity to its stable GlobalEntity identifier, or returns an error if not found.
Source§

impl<E: Copy + Eq + Hash + Send + Sync> GlobalEntitySpawner<E> for GlobalEntityMap<E>

Source§

fn spawn( &mut self, world_entity: E, remote_entity_opt: Option<RemoteEntity>, ) -> GlobalEntity

Registers world_entity in the map, reusing a reserved GlobalEntity for remote_entity_opt if one exists.
Source§

fn reserve_global_entity(&mut self, remote_entity: RemoteEntity) -> GlobalEntity

Pre-allocates a GlobalEntity slot for remote_entity before the local world entity is spawned.
Source§

fn despawn_by_global(&mut self, global_entity: &GlobalEntity)

Removes the mapping keyed by global_entity, panicking if it does not exist.
Source§

fn despawn_by_world(&mut self, world_entity: &E)

Removes the mapping keyed by world_entity, panicking if it does not exist.
Source§

fn to_converter(&self) -> &dyn EntityAndGlobalEntityConverter<E>

Returns self as an EntityAndGlobalEntityConverter reference for read-only lookups.

Auto Trait Implementations§

§

impl<E> Freeze for GlobalEntityMap<E>

§

impl<E> RefUnwindSafe for GlobalEntityMap<E>
where E: RefUnwindSafe,

§

impl<E> Send for GlobalEntityMap<E>

§

impl<E> Sync for GlobalEntityMap<E>

§

impl<E> Unpin for GlobalEntityMap<E>
where E: Unpin,

§

impl<E> UnsafeUnpin for GlobalEntityMap<E>

§

impl<E> UnwindSafe for GlobalEntityMap<E>
where E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V