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§
Source§impl<'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>(self) -> Result<&'a T, ComponentError>where
T: Component,
pub fn into_component<T>(self) -> Result<&'a T, ComponentError>where
T: Component,
Returns a reference to one of the entity’s components.
Sourcepub fn into_component_mut<T>(self) -> Result<&'a mut T, ComponentError>where
T: Component,
pub fn into_component_mut<T>(self) -> Result<&'a mut T, ComponentError>where
T: Component,
Returns a mutable reference to one of the entity’s components.
Sourcepub unsafe fn into_component_unchecked<T>(
self,
) -> Result<&'a mut T, ComponentError>where
T: Component,
pub unsafe fn into_component_unchecked<T>(
self,
) -> Result<&'a mut T, ComponentError>where
T: Component,
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>(&self) -> Result<&T, ComponentError>where
T: Component,
pub fn get_component<T>(&self) -> Result<&T, ComponentError>where
T: Component,
Returns a reference to one of the entity’s components.
Sourcepub fn get_component_mut<T>(&mut self) -> Result<&mut T, ComponentError>where
T: Component,
pub fn get_component_mut<T>(&mut self) -> Result<&mut T, ComponentError>where
T: Component,
Returns a mutable reference to one of the entity’s components.
Sourcepub unsafe fn get_component_unchecked<T>(
&self,
) -> Result<&mut T, ComponentError>where
T: Component,
pub unsafe fn get_component_unchecked<T>(
&self,
) -> Result<&mut T, ComponentError>where
T: Component,
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>(&mut self, component: T)where
T: Component,
pub fn add_component<T>(&mut self, component: T)where
T: Component,
Adds a new component to the entity. If the component already exists, its value will be replaced.
Sourcepub fn remove_component<T>(&mut self)where
T: Component,
pub fn remove_component<T>(&mut self)where
T: Component,
Removes a component from the entity. Does nothing if the entity does not have the component.
Auto Trait Implementations§
impl<'a> Freeze for Entry<'a>
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§
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> Component for T
impl<T> Component for T
Source§type Storage = PackedStorage<T>
type Storage = PackedStorage<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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more