pub struct RemoteAllocator { /* private fields */ }Expand description
This is a stripped down entity allocator that operates on fewer assumptions than EntityAllocator.
As a result, using this will be slower than the main allocator but this offers additional freedoms.
In particular, this type is fully owned, allowing you to allocate entities for a world without locking or holding reference to the world.
This is especially useful in async contexts.
Implementations§
Source§impl RemoteAllocator
impl RemoteAllocator
Sourcepub fn alloc(&self) -> Entity
pub fn alloc(&self) -> Entity
Allocates an entity remotely.
This comes with a major downside:
Because this does not hold reference to the world, the world may be cleared or destroyed before you get a chance to use the result.
If that happens, these entities will be garbage!
They will not be unique in the world anymore and you should not spawn them!
Before using the returned values in the world, first check that it is ok with EntityAllocator::has_remote_allocator.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Returns whether or not this RemoteAllocator is still connected to its source EntityAllocator.
Note that this could close immediately after the function returns false, so be careful.
The best way to ensure that does not happen is to only trust the returned value while holding a reference to the world
and to ensure it is the right world through EntityAllocator::has_remote_allocator.
This is generally best used as a diagnostic.
EntityAllocator::has_remote_allocator is a better check for correctness.
Trait Implementations§
Source§impl Clone for RemoteAllocator
impl Clone for RemoteAllocator
Source§fn clone(&self) -> RemoteAllocator
fn clone(&self) -> RemoteAllocator
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RemoteAllocator
impl RefUnwindSafe for RemoteAllocator
impl Send for RemoteAllocator
impl Sync for RemoteAllocator
impl Unpin for RemoteAllocator
impl UnsafeUnpin for RemoteAllocator
impl UnwindSafe for RemoteAllocator
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,
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>, which can then be
downcast into Box<dyn 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>, which 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.