Trait QueryFilter

Source
pub trait QueryFilter: QueryFilter { }
Expand description

A sealed structural component-presence predicate for World::query_filtered.

Filters are types, not values or component accesses. With<T> and Without<T> test whether a live entity has a component of exactly type T. They do not inspect tag values (see the engine’s separate tags::TagPredicate). Tuples and All require every clause; Any requires at least one; Not negates a predicate. Groups have zero to four clauses and may nest. Empty conjunctions ((), All<()>) are true; Any<()> is false. Negation applies within the live entity universe; dead slots are always excluded. See World::query_filtered for a runnable tick-system recipe.

use ferravex_ecs::{All, Any, Entity, Not, With, Without, World};
let mut world = World::new();
let tagged = world.spawn((1_u32,));
world.spawn(());
assert_eq!(world.query_filtered::<Entity, All<(With<u32>, Without<bool>)>>()
    .iter().collect::<Vec<_>>(), [tagged]);
assert_eq!(world.query_filtered::<Entity, Any<()>>().iter().count(), 0);
assert_eq!(world.query_filtered::<Entity, Not<Any<()>>>().iter().count(), 2);

Each tuple group is bounded to four clauses. Nest a group to combine more:

ⓘ
use ferravex_ecs::{Any, Entity, With, World};
let world = World::new();
world.query_filtered::<Entity, Any<(
    With<u8>, With<u16>, With<u32>, With<u64>, With<bool>
)>>(); // Five clauses in one group are unsupported.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl QueryFilter for ()

Source§

impl<A> QueryFilter for (A,)
where A: QueryFilter,

Source§

impl<A, B> QueryFilter for (A, B)
where A: QueryFilter, B: QueryFilter,

Source§

impl<A, B, C> QueryFilter for (A, B, C)

Source§

impl<A, B, C, D> QueryFilter for (A, B, C, D)

Implementors§

Source§

impl QueryFilter for All<()>

Source§

impl QueryFilter for Any<()>

Source§

impl<A> QueryFilter for All<(A,)>
where A: QueryFilter,

Source§

impl<A> QueryFilter for Any<(A,)>
where A: QueryFilter,

Source§

impl<A, B> QueryFilter for All<(A, B)>
where A: QueryFilter, B: QueryFilter,

Source§

impl<A, B> QueryFilter for Any<(A, B)>
where A: QueryFilter, B: QueryFilter,

Source§

impl<A, B, C> QueryFilter for All<(A, B, C)>

Source§

impl<A, B, C> QueryFilter for Any<(A, B, C)>

Source§

impl<A, B, C, D> QueryFilter for All<(A, B, C, D)>

Source§

impl<A, B, C, D> QueryFilter for Any<(A, B, C, D)>

Source§

impl<F> QueryFilter for Not<F>
where F: QueryFilter,

Source§

impl<T> QueryFilter for With<T>
where T: 'static,

Source§

impl<T> QueryFilter for Without<T>
where T: 'static,