Skip to main content

WorldQuery

Trait WorldQuery 

Source
pub trait WorldQuery {
    type Item<'w>;

    // Required methods
    fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>;
    fn contains(world: &World, id: EntityId) -> bool;
}
Expand description

Describes what data a query fetches for each matching entity.

Implementations exist for:

  • EntityId — passes through the entity ID
  • &T for built-in components — reads from the component’s SecondaryMap
  • Option<&T> for built-in components — optional read (always matches)
  • &Ext<T> for extension components — read from extension storage
  • Tuples of the above (up to arity 8)

Required Associated Types§

Source

type Item<'w>

The item yielded per entity.

Required Methods§

Source

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Try to fetch data for a single entity. Returns None if missing.

Source

fn contains(world: &World, id: EntityId) -> bool

Check component presence without extracting data.

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 WorldQuery for Option<&Elevator>

Source§

type Item<'w> = Option<&'w Elevator>

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(_world: &World, _id: EntityId) -> bool

Source§

impl WorldQuery for Option<&Line>

Source§

type Item<'w> = Option<&'w Line>

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(_world: &World, _id: EntityId) -> bool

Source§

impl WorldQuery for Option<&Patience>

Source§

type Item<'w> = Option<&'w Patience>

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(_world: &World, _id: EntityId) -> bool

Source§

impl WorldQuery for Option<&Preferences>

Source§

type Item<'w> = Option<&'w Preferences>

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(_world: &World, _id: EntityId) -> bool

Source§

impl WorldQuery for Option<&Position>

Source§

type Item<'w> = Option<&'w Position>

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(_world: &World, _id: EntityId) -> bool

Source§

impl WorldQuery for Option<&Velocity>

Source§

type Item<'w> = Option<&'w Velocity>

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(_world: &World, _id: EntityId) -> bool

Source§

impl WorldQuery for Option<&Rider>

Source§

type Item<'w> = Option<&'w Rider>

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(_world: &World, _id: EntityId) -> bool

Source§

impl WorldQuery for Option<&Route>

Source§

type Item<'w> = Option<&'w Route>

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(_world: &World, _id: EntityId) -> bool

Source§

impl WorldQuery for Option<&Stop>

Source§

type Item<'w> = Option<&'w Stop>

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(_world: &World, _id: EntityId) -> bool

Source§

impl<A: WorldQuery> WorldQuery for (A,)

Source§

type Item<'w> = (<A as WorldQuery>::Item<'w>,)

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(world: &World, id: EntityId) -> bool

Source§

impl<A: WorldQuery, B: WorldQuery> WorldQuery for (A, B)

Source§

type Item<'w> = (<A as WorldQuery>::Item<'w>, <B as WorldQuery>::Item<'w>)

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(world: &World, id: EntityId) -> bool

Source§

impl<A: WorldQuery, B: WorldQuery, C: WorldQuery> WorldQuery for (A, B, C)

Source§

type Item<'w> = (<A as WorldQuery>::Item<'w>, <B as WorldQuery>::Item<'w>, <C as WorldQuery>::Item<'w>)

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(world: &World, id: EntityId) -> bool

Source§

impl<A: WorldQuery, B: WorldQuery, C: WorldQuery, D: WorldQuery> WorldQuery for (A, B, C, D)

Source§

type Item<'w> = (<A as WorldQuery>::Item<'w>, <B as WorldQuery>::Item<'w>, <C as WorldQuery>::Item<'w>, <D as WorldQuery>::Item<'w>)

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(world: &World, id: EntityId) -> bool

Source§

impl<A: WorldQuery, B: WorldQuery, C: WorldQuery, D: WorldQuery, E: WorldQuery> WorldQuery for (A, B, C, D, E)

Source§

type Item<'w> = (<A as WorldQuery>::Item<'w>, <B as WorldQuery>::Item<'w>, <C as WorldQuery>::Item<'w>, <D as WorldQuery>::Item<'w>, <E as WorldQuery>::Item<'w>)

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(world: &World, id: EntityId) -> bool

Source§

impl<A: WorldQuery, B: WorldQuery, C: WorldQuery, D: WorldQuery, E: WorldQuery, F: WorldQuery> WorldQuery for (A, B, C, D, E, F)

Source§

type Item<'w> = (<A as WorldQuery>::Item<'w>, <B as WorldQuery>::Item<'w>, <C as WorldQuery>::Item<'w>, <D as WorldQuery>::Item<'w>, <E as WorldQuery>::Item<'w>, <F as WorldQuery>::Item<'w>)

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(world: &World, id: EntityId) -> bool

Source§

impl<A: WorldQuery, B: WorldQuery, C: WorldQuery, D: WorldQuery, E: WorldQuery, F: WorldQuery, G: WorldQuery> WorldQuery for (A, B, C, D, E, F, G)

Source§

type Item<'w> = (<A as WorldQuery>::Item<'w>, <B as WorldQuery>::Item<'w>, <C as WorldQuery>::Item<'w>, <D as WorldQuery>::Item<'w>, <E as WorldQuery>::Item<'w>, <F as WorldQuery>::Item<'w>, <G as WorldQuery>::Item<'w>)

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(world: &World, id: EntityId) -> bool

Source§

impl<A: WorldQuery, B: WorldQuery, C: WorldQuery, D: WorldQuery, E: WorldQuery, F: WorldQuery, G: WorldQuery, H: WorldQuery> WorldQuery for (A, B, C, D, E, F, G, H)

Source§

type Item<'w> = (<A as WorldQuery>::Item<'w>, <B as WorldQuery>::Item<'w>, <C as WorldQuery>::Item<'w>, <D as WorldQuery>::Item<'w>, <E as WorldQuery>::Item<'w>, <F as WorldQuery>::Item<'w>, <G as WorldQuery>::Item<'w>, <H as WorldQuery>::Item<'w>)

Source§

fn fetch(world: &World, id: EntityId) -> Option<Self::Item<'_>>

Source§

fn contains(world: &World, id: EntityId) -> bool

Implementors§