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.entity_with_bundle((123, "123", 123.0));
let mut query = world.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
sourceimpl<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 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_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 last_changed(&self) -> u64
pub fn last_changed(&self) -> u64
Return the last time this component was changed.