Entry

Struct Entry 

Source
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>

Source

pub fn new(id: usize, value: T) -> Self

Source

pub fn id(&self) -> usize

Get the identifier of the entity this component is associated with.

Source

pub fn value(&self) -> &T

Get a reference to the component value.

Source

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.

Source

pub fn into_inner(self) -> T

Source

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.

Source

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.

Source

pub fn was_added_since(&self, iteration: u64) -> bool

Determine if the component has been added since the given iteration timestamp.

Source

pub fn was_added_after(&self, iteration: u64) -> bool

Determine if the component was added after the given iteration timestamp.

Source

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.

Source

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.

Source

pub fn last_changed(&self) -> u64

Return the last time this component was changed.

Trait Implementations§

Source§

impl<T> AsRef<T> for Entry<T>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Clone> Clone for Entry<T>

Source§

fn clone(&self) -> Entry<T>

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Entry<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Deref for Entry<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T> DerefMut for Entry<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T: PartialEq> PartialEq for Entry<T>

Source§

fn eq(&self, other: &Entry<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> SatisfyTraits<dyn Cloneable> for T
where T: Clone,

Source§

impl<T> SatisfyTraits<dyn Cloneable + Send> for T
where T: Clone + Send,

Source§

impl<T> SatisfyTraits<dyn Cloneable + Send + Sync> for T
where T: Clone + Send + Sync,

Source§

impl<T> SatisfyTraits<dyn Cloneable + Sync> for T
where T: Clone + Sync,

Source§

impl<T> SatisfyTraits<dyn None> for T

Source§

impl<T> SatisfyTraits<dyn Send> for T
where T: Send,

Source§

impl<T> SatisfyTraits<dyn Send + Sync> for T
where T: Send + Sync,

Source§

impl<T> SatisfyTraits<dyn Sync> for T
where T: Sync,