pub struct Query<V, F = <<V as IntoView>::View as DefaultFilter>::Filter>where
V: IntoView,
F: EntityFilter,{ /* 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§
Source§impl<V, F> Query<V, F>where
V: IntoView,
F: EntityFilter,
impl<V, F> Query<V, F>where
V: IntoView,
F: EntityFilter,
Sourcepub fn filter<T>(self, filter: T) -> Query<V, <F as BitAnd<T>>::Output>
pub fn filter<T>(self, filter: T) -> Query<V, <F as BitAnd<T>>::Output>
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 as IntoView>::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 as IntoView>::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 as IntoView>::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 as IntoView>::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 as IntoView>::View as View<'world>>::Element, EntityAccessError>
pub fn get<'query, 'world, T>( &'query mut self, world: &'world T, entity: Entity, ) -> Result<<<V as IntoView>::View as View<'world>>::Element, EntityAccessError>
Returns the components for a single entity.
Sourcepub unsafe fn iter_chunks_unchecked<'query, 'world, T>(
&'query mut self,
world: &'world T,
) -> ChunkIter<'world, 'query, <V as IntoView>::View, F> ⓘwhere
T: EntityStore,
pub unsafe fn iter_chunks_unchecked<'query, 'world, T>(
&'query mut self,
world: &'world T,
) -> ChunkIter<'world, 'query, <V as IntoView>::View, F> ⓘwhere
T: EntityStore,
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 unsafe fn par_iter_chunks_unchecked<'a, T>(
&'a mut self,
world: &'a T,
) -> ParChunkIter<'a, <V as IntoView>::View, F>where
T: EntityStore,
pub unsafe fn par_iter_chunks_unchecked<'a, T>(
&'a mut self,
world: &'a T,
) -> ParChunkIter<'a, <V as IntoView>::View, F>where
T: EntityStore,
Returns a parallel 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>(
&'query mut self,
world: &'world mut T,
) -> ChunkIter<'world, 'query, <V as IntoView>::View, F> ⓘwhere
T: EntityStore,
pub fn iter_chunks_mut<'query, 'world, T>(
&'query mut self,
world: &'world mut T,
) -> ChunkIter<'world, 'query, <V as IntoView>::View, F> ⓘwhere
T: EntityStore,
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 par_iter_chunks_mut<'a, T>(
&'a mut self,
world: &'a mut T,
) -> ParChunkIter<'a, <V as IntoView>::View, F>where
T: EntityStore,
pub fn par_iter_chunks_mut<'a, T>(
&'a mut self,
world: &'a mut T,
) -> ParChunkIter<'a, <V as IntoView>::View, F>where
T: EntityStore,
Returns a parallel 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>(
&'query mut self,
world: &'world T,
) -> ChunkIter<'world, 'query, <V as IntoView>::View, F> ⓘ
pub fn iter_chunks<'query, 'world, T>( &'query mut self, world: &'world T, ) -> ChunkIter<'world, 'query, <V as IntoView>::View, F> ⓘ
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 fn par_iter_chunks<'a, T>(
&'a mut self,
world: &'a T,
) -> ParChunkIter<'a, <V as IntoView>::View, F>
pub fn par_iter_chunks<'a, T>( &'a mut self, world: &'a T, ) -> ParChunkIter<'a, <V as IntoView>::View, F>
Returns a parallel 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>(
&'query mut self,
world: &'world T,
) -> Flatten<ChunkIter<'world, 'query, <V as IntoView>::View, F>>where
T: EntityStore,
pub unsafe fn iter_unchecked<'query, 'world, T>(
&'query mut self,
world: &'world T,
) -> Flatten<ChunkIter<'world, 'query, <V as IntoView>::View, F>>where
T: EntityStore,
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 unsafe fn par_iter_unchecked<'a, T>(
&'a mut self,
world: &'a T,
) -> Flatten<ParChunkIter<'a, <V as IntoView>::View, F>>where
T: EntityStore,
pub unsafe fn par_iter_unchecked<'a, T>(
&'a mut self,
world: &'a T,
) -> Flatten<ParChunkIter<'a, <V as IntoView>::View, F>>where
T: EntityStore,
Returns a parallel iterator which will yield 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 iter_mut<'query, 'world, T>(
&'query mut self,
world: &'world mut T,
) -> Flatten<ChunkIter<'world, 'query, <V as IntoView>::View, F>>where
T: EntityStore,
pub fn iter_mut<'query, 'world, T>(
&'query mut self,
world: &'world mut T,
) -> Flatten<ChunkIter<'world, 'query, <V as IntoView>::View, F>>where
T: EntityStore,
Returns an iterator which will yield all components which match the query.
Prefer for_each_mut
as it yields better performance.
Sourcepub fn par_iter_mut<'a, T>(
&'a mut self,
world: &'a mut T,
) -> Flatten<ParChunkIter<'a, <V as IntoView>::View, F>>where
T: EntityStore,
pub fn par_iter_mut<'a, T>(
&'a mut self,
world: &'a mut T,
) -> Flatten<ParChunkIter<'a, <V as IntoView>::View, F>>where
T: EntityStore,
Returns a parallel iterator which will yield all components which match the query.
Sourcepub fn iter<'query, 'world, T>(
&'query mut self,
world: &'world T,
) -> Flatten<ChunkIter<'world, 'query, <V as IntoView>::View, F>>
pub fn iter<'query, 'world, T>( &'query mut self, world: &'world T, ) -> Flatten<ChunkIter<'world, 'query, <V as IntoView>::View, F>>
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 fn par_iter<'a, T>(
&'a mut self,
world: &'a T,
) -> Flatten<ParChunkIter<'a, <V as IntoView>::View, F>>
pub fn par_iter<'a, T>( &'a mut self, world: &'a T, ) -> Flatten<ParChunkIter<'a, <V as IntoView>::View, F>>
Returns a parallel iterator which will yield all components which match the query.
Only usable with queries whose views are read-only.
Sourcepub unsafe fn for_each_chunk_unchecked<'query, 'world, T, Body>(
&'query mut self,
world: &'world T,
f: Body,
)
pub unsafe fn for_each_chunk_unchecked<'query, 'world, T, Body>( &'query mut self, world: &'world T, f: Body, )
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 unsafe fn par_for_each_chunk_unchecked<'a, T, Body>(
&'a mut self,
world: &'a T,
f: Body,
)
pub unsafe fn par_for_each_chunk_unchecked<'a, T, Body>( &'a mut self, world: &'a T, f: Body, )
Iterates in parallel 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, Body>(
&'query mut self,
world: &'world mut T,
f: Body,
)
pub fn for_each_chunk_mut<'query, 'world, T, Body>( &'query mut self, world: &'world mut T, f: Body, )
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 par_for_each_chunk_mut<'a, T, Body>(
&'a mut self,
world: &'a mut T,
f: Body,
)
pub fn par_for_each_chunk_mut<'a, T, Body>( &'a mut self, world: &'a mut T, f: Body, )
Iterates in parallel 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, Body>(
&'query mut self,
world: &'world T,
f: Body,
)
pub fn for_each_chunk<'query, 'world, T, Body>( &'query mut self, world: &'world T, f: Body, )
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 fn par_for_each_chunk<'a, T, Body>(&'a mut self, world: &'a T, f: Body)
pub fn par_for_each_chunk<'a, T, Body>(&'a mut self, world: &'a T, f: Body)
Iterates in parallel 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, Body>(
&'query mut self,
world: &'world T,
f: Body,
)
pub unsafe fn for_each_unchecked<'query, 'world, T, Body>( &'query mut self, world: &'world T, f: Body, )
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 unsafe fn par_for_each_unchecked<'a, T, Body>(
&'a mut self,
world: &'a T,
f: Body,
)
pub unsafe fn par_for_each_unchecked<'a, T, Body>( &'a mut self, world: &'a T, f: Body, )
Iterates in parallel 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, Body>(
&'query mut self,
world: &'world mut T,
f: Body,
)
pub fn for_each_mut<'query, 'world, T, Body>( &'query mut self, world: &'world mut T, f: Body, )
Iterates through all components which match the query.
Sourcepub fn par_for_each_mut<'a, T, Body>(&'a mut self, world: &'a mut T, f: Body)
pub fn par_for_each_mut<'a, T, Body>(&'a mut self, world: &'a mut T, f: Body)
Iterates in parallel through all components which match the query.
Sourcepub fn for_each<'query, 'world, T, Body>(
&'query mut self,
world: &'world T,
f: Body,
)
pub fn for_each<'query, 'world, T, Body>( &'query mut self, world: &'world T, f: Body, )
Iterates through all components which match the query.
Only usable with queries whose views are read-only.
Sourcepub fn par_for_each<'a, T, Body>(&'a mut self, world: &'a T, f: Body)
pub fn par_for_each<'a, T, Body>(&'a mut self, world: &'a T, f: Body)
Iterates in parallel through all components which match the query.
Only usable with queries whose views are read-only.
Trait Implementations§
Source§impl<V, F> Default for Query<V, F>where
V: IntoView,
F: EntityFilter,
impl<V, F> Default for Query<V, F>where
V: IntoView,
F: EntityFilter,
Auto Trait Implementations§
impl<V, F = <<V as IntoView>::View as DefaultFilter>::Filter> !Freeze for Query<V, F>
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>
impl<V, F> UnwindSafe for Query<V, F>where
V: UnwindSafe,
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Component for T
impl<T> Component for T
Source§type Storage = PackedStorage<T>
type Storage = PackedStorage<T>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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