pub struct Entry<T> { /* private fields */ }Expand description
A component value along with its entity’s id and change tracking information.
An entry is returned from component queries. It is a wrapper around a component that provides extra information about the last time the component was modified.
Entry implements Deref and DerefMut, but you can also obtain a
reference to the component value through Entry::value or
Entry::value_mut.
let mut world = World::default();
let e = world.get_entities_mut().create();
let cs = world.get_components_mut();
cs.insert_bundle(*e, (123, "123", 123.0));
let mut query = cs.query::<(&mut i32, &f64)>();
let (entry_i32, entry_f64): (&mut Entry<i32>, &Entry<f64>) = query.find_one(e.id()).unwrap();
**entry_i32 = 321;
assert_eq!(321 - 123, **entry_i32 - **entry_f64 as i32);
// both components were added (and one component modified) this iteration
assert_eq!(entry_i32.last_changed(), entry_f64.last_changed());Implementations§
Source§impl<T> Entry<T>
impl<T> Entry<T>
pub fn new(id: usize, value: T) -> Self
Sourcepub fn value_mut(&mut self) -> &mut T
pub fn value_mut(&mut self) -> &mut T
Get a mutable reference to the component value.
This updates the last time this copmonent was changed.
pub fn into_inner(self) -> T
Sourcepub fn has_changed_since(&self, iteration: u64) -> bool
pub fn has_changed_since(&self, iteration: u64) -> bool
Determine if the component has changed since the given iteration timestamp.
This includes being added or being modified.
Sourcepub fn has_changed_after(&self, iteration: u64) -> bool
pub fn has_changed_after(&self, iteration: u64) -> bool
Determine if the component has changed after the given iteration timestamp.
This includes being added or being modified.
Sourcepub fn was_added_since(&self, iteration: u64) -> bool
pub fn was_added_since(&self, iteration: u64) -> bool
Determine if the component has been added since the given iteration timestamp.
Sourcepub fn was_added_after(&self, iteration: u64) -> bool
pub fn was_added_after(&self, iteration: u64) -> bool
Determine if the component was added after the given iteration timestamp.
Sourcepub fn was_modified_since(&self, iteration: u64) -> bool
pub fn was_modified_since(&self, iteration: u64) -> bool
Determine if the component has been modified since the given iteration timestamp, but has not been added.
Sourcepub fn was_modified_after(&self, iteration: u64) -> bool
pub fn was_modified_after(&self, iteration: u64) -> bool
Determine if the component has been modified after the given iteration timestamp, but has not been added.
Sourcepub fn last_changed(&self) -> u64
pub fn last_changed(&self) -> u64
Return the last time this component was changed.
Trait Implementations§
impl<T> StructuralPartialEq for Entry<T>
Auto Trait Implementations§
impl<T> Freeze for Entry<T>where
T: Freeze,
impl<T> RefUnwindSafe for Entry<T>where
T: RefUnwindSafe,
impl<T> Send for Entry<T>where
T: Send,
impl<T> Sync for Entry<T>where
T: Sync,
impl<T> Unpin for Entry<T>where
T: Unpin,
impl<T> UnwindSafe for Entry<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)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