pub struct Entry<'a> { /* private fields */ }
Expand description
Provides safe read and write access to an entity’s components, and the ability to modify the entity.
Implementations
sourceimpl<'a> Entry<'a>
impl<'a> Entry<'a>
sourcepub fn location(&self) -> EntityLocation
pub fn location(&self) -> EntityLocation
Returns the entity’s location.
sourcepub fn into_component<T: Component>(self) -> Result<&'a T, ComponentError>
pub fn into_component<T: Component>(self) -> Result<&'a T, ComponentError>
Returns a reference to one of the entity’s components.
sourcepub fn into_component_mut<T: Component>(
self
) -> Result<&'a mut T, ComponentError>
pub fn into_component_mut<T: Component>(
self
) -> Result<&'a mut T, ComponentError>
Returns a mutable reference to one of the entity’s components.
sourcepub unsafe fn into_component_unchecked<T: Component>(
self
) -> Result<&'a mut T, ComponentError>
pub unsafe fn into_component_unchecked<T: Component>(
self
) -> Result<&'a mut T, ComponentError>
Returns a mutable reference to one of the entity’s components.
Safety
This function bypasses static borrow checking. The caller must ensure that the component reference will not be mutably aliased.
sourcepub fn get_component<T: Component>(&self) -> Result<&T, ComponentError>
pub fn get_component<T: Component>(&self) -> Result<&T, ComponentError>
Returns a reference to one of the entity’s components.
sourcepub fn get_component_mut<T: Component>(
&mut self
) -> Result<&mut T, ComponentError>
pub fn get_component_mut<T: Component>(
&mut self
) -> Result<&mut T, ComponentError>
Returns a mutable reference to one of the entity’s components.
sourcepub unsafe fn get_component_unchecked<T: Component>(
&self
) -> Result<&mut T, ComponentError>
pub unsafe fn get_component_unchecked<T: Component>(
&self
) -> Result<&mut T, ComponentError>
Returns a mutable reference to one of the entity’s components.
Safety
This function bypasses static borrow checking. The caller must ensure that the component reference will not be mutably aliased.
sourcepub fn add_component<T: Component>(&mut self, component: T)
pub fn add_component<T: Component>(&mut self, component: T)
Adds a new component to the entity. If the component already exists, its value will be replaced.
sourcepub fn remove_component<T: Component>(&mut self)
pub fn remove_component<T: Component>(&mut self)
Removes a component from the entity. Does nothing if the entity does not have the component.
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Entry<'a>
impl<'a> Send for Entry<'a>
impl<'a> Sync for Entry<'a>
impl<'a> Unpin for Entry<'a>
impl<'a> !UnwindSafe for Entry<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
sourcepub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert 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
. Read more
sourcepub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcepub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
sourcepub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more