Struct legion::Query[][src]

pub struct Query<V: IntoView, F: EntityFilter = <<V as IntoView>::View as DefaultFilter>::Filter> { /* fields omitted */ }

Provides efficient means to iterate and filter entities in a world.

See the module-level documentation for more details and examples.

Implementations

impl<V: IntoView, F: EntityFilter> Query<V, F>[src]

pub fn new() -> Self[src]

Consructs a new Query

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
[src]

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
[src]

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
[src]

Returns the components for a single entity.

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, 
[src]

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>

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>;
[src]

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 unsafe fn par_iter_chunks_unchecked<'a, T: EntityStore>(
    &'a mut self,
    world: &'a T
) -> ParChunkIter<'a, V::View, F>
[src]

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.

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>;
[src]

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 par_iter_chunks_mut<'a, T: EntityStore>(
    &'a mut self,
    world: &'a mut T
) -> ParChunkIter<'a, V::View, F>
[src]

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.

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, 
[src]

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 fn par_iter_chunks<'a, T: EntityStore>(
    &'a mut self,
    world: &'a T
) -> ParChunkIter<'a, V::View, F> where
    <V::View as View<'a>>::Fetch: ReadOnlyFetch, 
[src]

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.

pub unsafe fn iter_unchecked<'query, 'world, T: EntityStore>(
    &'query mut self,
    world: &'world T
) -> Flatten<ChunkIter<'world, 'query, V::View, F>>
[src]

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 unsafe fn par_iter_unchecked<'a, T: EntityStore>(
    &'a mut self,
    world: &'a T
) -> Flatten<ParChunkIter<'a, V::View, F>>
[src]

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.

pub fn iter_mut<'query, 'world, T: EntityStore>(
    &'query mut self,
    world: &'world mut T
) -> Flatten<ChunkIter<'world, 'query, V::View, F>>
[src]

Returns an iterator which will yield all components which match the query.

Prefer for_each_mut as it yields better performance.

pub fn par_iter_mut<'a, T: EntityStore>(
    &'a mut self,
    world: &'a mut T
) -> Flatten<ParChunkIter<'a, V::View, F>>
[src]

Returns a parallel iterator which will yield all components which match the query.

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, 
[src]

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 fn par_iter<'a, T: EntityStore>(
    &'a mut self,
    world: &'a T
) -> Flatten<ParChunkIter<'a, V::View, F>> where
    <V::View as View<'a>>::Fetch: ReadOnlyFetch, 
[src]

Returns a parallel iterator which will yield all components which match the query.

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>), 
[src]

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 unsafe fn par_for_each_chunk_unchecked<'a, T: EntityStore, Body>(
    &'a mut self,
    world: &'a T,
    f: Body
) where
    Body: Fn(ChunkView<'_, <V::View as View<'a>>::Fetch>) + Send + Sync
[src]

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.

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>), 
[src]

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 par_for_each_chunk_mut<'a, T: EntityStore, Body>(
    &'a mut self,
    world: &'a mut T,
    f: Body
) where
    Body: Fn(ChunkView<'_, <V::View as View<'a>>::Fetch>) + Send + Sync
[src]

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.

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, 
[src]

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 fn par_for_each_chunk<'a, T: EntityStore, Body>(
    &'a mut self,
    world: &'a T,
    f: Body
) where
    Body: Fn(ChunkView<'_, <V::View as View<'a>>::Fetch>) + Send + Sync,
    <V::View as View<'a>>::Fetch: ReadOnlyFetch, 
[src]

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.

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), 
[src]

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 unsafe fn par_for_each_unchecked<'a, T: EntityStore, Body>(
    &'a mut self,
    world: &'a T,
    f: Body
) where
    Body: Fn(<V::View as View<'a>>::Element) + Send + Sync
[src]

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.

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), 
[src]

Iterates through all components which match the query.

pub fn par_for_each_mut<'a, T: EntityStore, Body>(
    &'a mut self,
    world: &'a mut T,
    f: Body
) where
    Body: Fn(<V::View as View<'a>>::Element) + Send + Sync
[src]

Iterates in parallel through all components which match the query.

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, 
[src]

Iterates through all components which match the query.

Only usable with queries whose views are read-only.

pub fn par_for_each<'a, T: EntityStore, Body>(
    &'a mut self,
    world: &'a T,
    f: Body
) where
    Body: Fn(<V::View as View<'a>>::Element) + Send + Sync,
    <V::View as View<'a>>::Fetch: ReadOnlyFetch, 
[src]

Iterates in parallel through all components which match the query.

Only usable with queries whose views are read-only.

Trait Implementations

impl<V: IntoView, F: EntityFilter> Default for Query<V, F>[src]

impl<AV, AF> QuerySet for Query<AV, AF> where
    AV: IntoView + Send + Sync,
    AF: EntityFilter
[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Send + Sync + Any
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.