pub struct Query<Q, F = All>where
    Q: for<'x> Fetch<'x>,
    F: for<'x> Filter<'x>,
{ /* private fields */ }
Expand description

Represents a query and state for a given world. The archetypes to visit is cached in the query which means it is more performant to reuse the query than creating a new one.

The archetype borrowing assures aliasing. Two of the same queries can be run at the same time as long as they don’t borrow an archetype’s component mutably at the same time.

Implementations

Construct a new query which will fetch all items in the given query. The query can be either a singular component, a tuple of components, or any other type which implements crate::Fetch.

Note: The query will not yield components, as it may not be intended behaviour since the most common intent is the entities. See Query::with_components

A fetch may also contain filters

Include component entities for the query. The default is to hide components as they are usually not desired during iteration.

Adds a new filter to the query. This filter is and:ed with the existing filters.

Shortcut for filter(without)

Shortcut for filter(with)

Returns the last change tick the query was run on. Any changes > change_tick will be yielded in a query iteration.

Returns true if the query will mutate any components

Borrow the world for the query.

Allows for both random access and efficient iteration. See: QueryBorrow::get and QueryBorrow::iter

The returned value holds the borrows of the query fetch. As such, all references from iteration or using QueryBorrow::get] will have a lifetime of the [QueryBorrow`.

This is because iterators can not yield references to internal state as all items returned by the iterator need to coexist.

It is safe to use the same prepared query for both iteration and random access, Rust’s borrow rules will ensure aliasing rules.

Gathers all elements in the query as a Vec of owned values.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns all the accesses for a system

The borrow from the system context

Get the data from the system context

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.