pub struct Query<V: IntoView, F: EntityFilter = <<V as IntoView>::View as DefaultFilter>::Filter> { /* private fields */ }
Expand description
Provides efficient means to iterate and filter entities in a world.
See the module-level documentation for more details and examples.
Implementations
sourceimpl<V: IntoView, F: EntityFilter> Query<V, F>
impl<V: IntoView, F: EntityFilter> Query<V, F>
sourcepub fn filter<T: EntityFilter>(
self,
filter: T
) -> Query<V, <F as BitAnd<T>>::Output> where
F: BitAnd<T>,
<F as BitAnd<T>>::Output: EntityFilter,
pub fn filter<T: EntityFilter>(
self,
filter: T
) -> Query<V, <F as BitAnd<T>>::Output> where
F: BitAnd<T>,
<F as BitAnd<T>>::Output: EntityFilter,
Adds an additional filter to the query.
sourcepub unsafe fn get_unchecked<'query, 'world, T>(
&'query mut self,
world: &'world T,
entity: Entity
) -> Result<<V::View as View<'world>>::Element, EntityAccessError> where
T: EntityStore,
pub unsafe fn get_unchecked<'query, 'world, T>(
&'query mut self,
world: &'world T,
entity: Entity
) -> Result<<V::View as View<'world>>::Element, EntityAccessError> where
T: EntityStore,
Returns the components for a single entity.
This function will not evaluate the query’s dynamic filters. This means, for example, that
calling get
on all entities in an archetype will not prevent maybe_changed
from returning
those entities the next time the query is iterated.
Safety
This function allows mutable access via a shared world reference. The caller is responsible for ensuring that no component accesses may create mutable aliases.
sourcepub fn get_mut<'query, 'world, T>(
&'query mut self,
world: &'world mut T,
entity: Entity
) -> Result<<V::View as View<'world>>::Element, EntityAccessError> where
T: EntityStore,
pub fn get_mut<'query, 'world, T>(
&'query mut self,
world: &'world mut T,
entity: Entity
) -> Result<<V::View as View<'world>>::Element, EntityAccessError> where
T: EntityStore,
Returns the components for a single entity.
sourcepub fn get<'query, 'world, T>(
&'query mut self,
world: &'world T,
entity: Entity
) -> Result<<V::View as View<'world>>::Element, EntityAccessError> where
T: EntityStore,
<V::View as View<'world>>::Fetch: ReadOnlyFetch,
pub fn get<'query, 'world, T>(
&'query mut self,
world: &'world T,
entity: Entity
) -> Result<<V::View as View<'world>>::Element, EntityAccessError> where
T: EntityStore,
<V::View as View<'world>>::Fetch: ReadOnlyFetch,
Returns the components for a single entity.
sourcepub unsafe fn iter_chunks_unchecked<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world T
) -> ChunkIter<'world, 'query, V::View, F>ⓘNotable traits for ChunkIter<'world, 'query, V, D>impl<'world, 'query, V, D> Iterator for ChunkIter<'world, 'query, V, D> where
V: View<'world>,
D: DynamicFilter + 'query, type Item = ChunkView<'world, V::Fetch>;
pub unsafe fn iter_chunks_unchecked<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world T
) -> ChunkIter<'world, 'query, V::View, F>ⓘNotable traits for ChunkIter<'world, 'query, V, D>impl<'world, 'query, V, D> Iterator for ChunkIter<'world, 'query, V, D> where
V: View<'world>,
D: DynamicFilter + 'query, type Item = ChunkView<'world, V::Fetch>;
V: View<'world>,
D: DynamicFilter + 'query, type Item = ChunkView<'world, V::Fetch>;
Returns an iterator which will yield all entity chunks which match the query.
Each chunk contains slices of components for entities which all have the same component layout.
Safety
This function allows mutable access via a shared world reference. The caller is responsible for ensuring that no component accesses may create mutable aliases.
sourcepub fn iter_chunks_mut<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world mut T
) -> ChunkIter<'world, 'query, V::View, F>ⓘNotable traits for ChunkIter<'world, 'query, V, D>impl<'world, 'query, V, D> Iterator for ChunkIter<'world, 'query, V, D> where
V: View<'world>,
D: DynamicFilter + 'query, type Item = ChunkView<'world, V::Fetch>;
pub fn iter_chunks_mut<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world mut T
) -> ChunkIter<'world, 'query, V::View, F>ⓘNotable traits for ChunkIter<'world, 'query, V, D>impl<'world, 'query, V, D> Iterator for ChunkIter<'world, 'query, V, D> where
V: View<'world>,
D: DynamicFilter + 'query, type Item = ChunkView<'world, V::Fetch>;
V: View<'world>,
D: DynamicFilter + 'query, type Item = ChunkView<'world, V::Fetch>;
Returns an iterator which will yield all entity chunks which match the query.
Each chunk contains slices of components for entities which all have the same component layout.
sourcepub fn iter_chunks<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world T
) -> ChunkIter<'world, 'query, V::View, F>ⓘNotable traits for ChunkIter<'world, 'query, V, D>impl<'world, 'query, V, D> Iterator for ChunkIter<'world, 'query, V, D> where
V: View<'world>,
D: DynamicFilter + 'query, type Item = ChunkView<'world, V::Fetch>;
where
<V::View as View<'world>>::Fetch: ReadOnlyFetch,
pub fn iter_chunks<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world T
) -> ChunkIter<'world, 'query, V::View, F>ⓘNotable traits for ChunkIter<'world, 'query, V, D>impl<'world, 'query, V, D> Iterator for ChunkIter<'world, 'query, V, D> where
V: View<'world>,
D: DynamicFilter + 'query, type Item = ChunkView<'world, V::Fetch>;
where
<V::View as View<'world>>::Fetch: ReadOnlyFetch,
V: View<'world>,
D: DynamicFilter + 'query, type Item = ChunkView<'world, V::Fetch>;
Returns an iterator which will yield all entity chunks which match the query.
Each chunk contains slices of components for entities which all have the same component layout.
Only usable with queries whose views are read-only.
sourcepub unsafe fn iter_unchecked<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world T
) -> Flatten<ChunkIter<'world, 'query, V::View, F>>
pub unsafe fn iter_unchecked<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world T
) -> Flatten<ChunkIter<'world, 'query, V::View, F>>
Returns an iterator which will yield all components which match the query.
Prefer for_each_unchecked
as it offers better performance.
Safety
This function allows mutable access via a shared world reference. The caller is responsible for ensuring that no component accesses may create mutable aliases.
sourcepub fn iter_mut<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world mut T
) -> Flatten<ChunkIter<'world, 'query, V::View, F>>
pub fn iter_mut<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world mut T
) -> Flatten<ChunkIter<'world, 'query, V::View, F>>
Returns an iterator which will yield all components which match the query.
Prefer for_each_mut
as it yields better performance.
sourcepub fn iter<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world T
) -> Flatten<ChunkIter<'world, 'query, V::View, F>> where
<V::View as View<'world>>::Fetch: ReadOnlyFetch,
pub fn iter<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world T
) -> Flatten<ChunkIter<'world, 'query, V::View, F>> where
<V::View as View<'world>>::Fetch: ReadOnlyFetch,
Returns an iterator which will yield all components which match the query.
Prefer for_each
as it yields better performance.
Only usable with queries whose views are read-only.
sourcepub unsafe fn for_each_chunk_unchecked<'query, 'world, T: EntityStore, Body>(
&'query mut self,
world: &'world T,
f: Body
) where
Body: FnMut(ChunkView<'_, <V::View as View<'world>>::Fetch>),
pub unsafe fn for_each_chunk_unchecked<'query, 'world, T: EntityStore, Body>(
&'query mut self,
world: &'world T,
f: Body
) where
Body: FnMut(ChunkView<'_, <V::View as View<'world>>::Fetch>),
Iterates through all entity chunks which match the query.
Each chunk contains slices of components for entities which all have the same component layout.
Safety
This function allows mutable access via a shared world reference. The caller is responsible for ensuring that no component accesses may create mutable aliases.
sourcepub fn for_each_chunk_mut<'query, 'world, T: EntityStore, Body>(
&'query mut self,
world: &'world mut T,
f: Body
) where
Body: FnMut(ChunkView<'_, <V::View as View<'world>>::Fetch>),
pub fn for_each_chunk_mut<'query, 'world, T: EntityStore, Body>(
&'query mut self,
world: &'world mut T,
f: Body
) where
Body: FnMut(ChunkView<'_, <V::View as View<'world>>::Fetch>),
Iterates through all entity chunks which match the query.
Each chunk contains slices of components for entities which all have the same component layout.
sourcepub fn for_each_chunk<'query, 'world, T: EntityStore, Body>(
&'query mut self,
world: &'world T,
f: Body
) where
Body: FnMut(ChunkView<'_, <V::View as View<'world>>::Fetch>),
<V::View as View<'world>>::Fetch: ReadOnlyFetch,
pub fn for_each_chunk<'query, 'world, T: EntityStore, Body>(
&'query mut self,
world: &'world T,
f: Body
) where
Body: FnMut(ChunkView<'_, <V::View as View<'world>>::Fetch>),
<V::View as View<'world>>::Fetch: ReadOnlyFetch,
Iterates through all entity chunks which match the query.
Each chunk contains slices of components for entities which all have the same component layout.
Only usable with queries whose views are read-only.
sourcepub unsafe fn for_each_unchecked<'query, 'world, T: EntityStore, Body>(
&'query mut self,
world: &'world T,
f: Body
) where
Body: FnMut(<V::View as View<'world>>::Element),
pub unsafe fn for_each_unchecked<'query, 'world, T: EntityStore, Body>(
&'query mut self,
world: &'world T,
f: Body
) where
Body: FnMut(<V::View as View<'world>>::Element),
Iterates through all components which match the query.
Safety
This function allows mutable access via a shared world reference. The caller is responsible for ensuring that no component accesses may create mutable aliases.
sourcepub fn for_each_mut<'query, 'world, T: EntityStore, Body>(
&'query mut self,
world: &'world mut T,
f: Body
) where
Body: FnMut(<V::View as View<'world>>::Element),
pub fn for_each_mut<'query, 'world, T: EntityStore, Body>(
&'query mut self,
world: &'world mut T,
f: Body
) where
Body: FnMut(<V::View as View<'world>>::Element),
Iterates through all components which match the query.
sourcepub fn for_each<'query, 'world, T: EntityStore, Body>(
&'query mut self,
world: &'world T,
f: Body
) where
Body: FnMut(<V::View as View<'world>>::Element),
<V::View as View<'world>>::Fetch: ReadOnlyFetch,
pub fn for_each<'query, 'world, T: EntityStore, Body>(
&'query mut self,
world: &'world T,
f: Body
) where
Body: FnMut(<V::View as View<'world>>::Element),
<V::View as View<'world>>::Fetch: ReadOnlyFetch,
Iterates through all components which match the query.
Only usable with queries whose views are read-only.
Trait Implementations
sourceimpl<V: IntoView, F: EntityFilter> Default for Query<V, F>
impl<V: IntoView, F: EntityFilter> Default for Query<V, F>
sourceimpl<AV, AF> QuerySet for Query<AV, AF> where
AV: IntoView + Send + Sync,
AF: EntityFilter,
impl<AV, AF> QuerySet for Query<AV, AF> where
AV: IntoView + Send + Sync,
AF: EntityFilter,
sourcefn filter_archetypes(&mut self, world: &World, bitset: &mut BitSet)
fn filter_archetypes(&mut self, world: &World, bitset: &mut BitSet)
Evaluates the queries and records which archetypes they require access to into a bitset.
Auto Trait Implementations
impl<V, F = <<V as IntoView>::View as DefaultFilter>::Filter> !RefUnwindSafe for Query<V, F>
impl<V, F> Send for Query<V, F> where
V: Send,
impl<V, F> Sync for Query<V, F> where
V: Sync,
impl<V, F> Unpin for Query<V, F> where
F: Unpin,
V: Unpin,
impl<V, F> UnwindSafe for Query<V, F> where
F: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
sourcepub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert 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
. Read more
sourcepub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcepub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
sourcepub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more