Struct legion::query::Query [−][src]
pub struct Query<V: IntoView, F: EntityFilter = <<V as IntoView>::View as DefaultFilter>::Filter> { /* fields omitted */ }
Expand description
Provides efficient means to iterate and filter entities in a world.
See the module-level documentation for more details and examples.
Implementations
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,
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.
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,
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.
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,
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.
Returns the components for a single entity.
pub unsafe fn iter_chunks_unchecked<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world T
) -> ChunkIter<'world, 'query, V::View, F>ⓘ
pub unsafe fn iter_chunks_unchecked<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world T
) -> ChunkIter<'world, 'query, V::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.
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.
pub fn iter_chunks_mut<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world mut T
) -> ChunkIter<'world, 'query, V::View, F>ⓘ
pub fn iter_chunks_mut<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world mut T
) -> ChunkIter<'world, 'query, V::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.
pub fn iter_chunks<'query, 'world, T: EntityStore>(
&'query mut self,
world: &'world T
) -> ChunkIter<'world, 'query, V::View, F>ⓘ 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>ⓘ where
<V::View as View<'world>>::Fetch: ReadOnlyFetch,
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.
pub 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.
pub 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.
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.
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>),
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.
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>),
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.
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,
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.
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),
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.
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),
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.
Iterates through all components which match the query.
Only usable with queries whose views are read-only.
Trait Implementations
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> UnwindSafe for Query<V, F> where
F: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
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
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
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
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