Skip to main content

QuerySpec

Trait QuerySpec 

Source
pub trait QuerySpec {
    type Item<'w>;
    type State<'w>;

    // Required methods
    fn matches(layout: &ArchetypeLayout) -> bool;
    fn init_state<'w>(archetype: &'w Archetype) -> Option<Self::State<'w>>;
    fn len(state: &Self::State<'_>) -> usize;
    fn entity(state: &Self::State<'_>, row: usize) -> Entity;
    fn fetch<'w>(state: &Self::State<'w>, row: usize) -> Self::Item<'w>;
}
Expand description

Describes an immutable query fetch over matching archetypes.

Required Associated Types§

Source

type Item<'w>

Source

type State<'w>

Required Methods§

Source

fn matches(layout: &ArchetypeLayout) -> bool

Source

fn init_state<'w>(archetype: &'w Archetype) -> Option<Self::State<'w>>

Source

fn len(state: &Self::State<'_>) -> usize

Source

fn entity(state: &Self::State<'_>, row: usize) -> Entity

Source

fn fetch<'w>(state: &Self::State<'w>, row: usize) -> Self::Item<'w>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<A: Component, B: Component, C: Component, D: Component> QuerySpec for (&A, Option<&B>, Option<&C>, Option<&D>)

Source§

type Item<'w> = (&'w A, Option<&'w B>, Option<&'w C>, Option<&'w D>)

Source§

type State<'w> = (&'w [Entity], &'w Column<A>, Option<&'w Column<B>>, Option<&'w Column<C>>, Option<&'w Column<D>>)

Source§

fn matches(layout: &ArchetypeLayout) -> bool

Source§

fn init_state<'w>(archetype: &'w Archetype) -> Option<Self::State<'w>>

Source§

fn len(state: &Self::State<'_>) -> usize

Source§

fn entity(state: &Self::State<'_>, row: usize) -> Entity

Source§

fn fetch<'w>(state: &Self::State<'w>, row: usize) -> Self::Item<'w>

Source§

impl<A: Component, B: Component, C: Component> QuerySpec for (&A, &B, &C)

Source§

type Item<'w> = (&'w A, &'w B, &'w C)

Source§

type State<'w> = (&'w [Entity], &'w Column<A>, &'w Column<B>, &'w Column<C>)

Source§

fn matches(layout: &ArchetypeLayout) -> bool

Source§

fn init_state<'w>(archetype: &'w Archetype) -> Option<Self::State<'w>>

Source§

fn len(state: &Self::State<'_>) -> usize

Source§

fn entity(state: &Self::State<'_>, row: usize) -> Entity

Source§

fn fetch<'w>(state: &Self::State<'w>, row: usize) -> Self::Item<'w>

Source§

impl<A: Component, B: Component> QuerySpec for (&A, &B)

Source§

type Item<'w> = (&'w A, &'w B)

Source§

type State<'w> = (&'w [Entity], &'w Column<A>, &'w Column<B>)

Source§

fn matches(layout: &ArchetypeLayout) -> bool

Source§

fn init_state<'w>(archetype: &'w Archetype) -> Option<Self::State<'w>>

Source§

fn len(state: &Self::State<'_>) -> usize

Source§

fn entity(state: &Self::State<'_>, row: usize) -> Entity

Source§

fn fetch<'w>(state: &Self::State<'w>, row: usize) -> Self::Item<'w>

Source§

impl<A: Component, B: Component> QuerySpec for (&A, Option<&B>)

Source§

type Item<'w> = (&'w A, Option<&'w B>)

Source§

type State<'w> = (&'w [Entity], &'w Column<A>, Option<&'w Column<B>>)

Source§

fn matches(layout: &ArchetypeLayout) -> bool

Source§

fn init_state<'w>(archetype: &'w Archetype) -> Option<Self::State<'w>>

Source§

fn len(state: &Self::State<'_>) -> usize

Source§

fn entity(state: &Self::State<'_>, row: usize) -> Entity

Source§

fn fetch<'w>(state: &Self::State<'w>, row: usize) -> Self::Item<'w>

Source§

impl<T: Component> QuerySpec for &T

Source§

type Item<'w> = &'w T

Source§

type State<'w> = (&'w [Entity], &'w Column<T>)

Source§

fn matches(layout: &ArchetypeLayout) -> bool

Source§

fn init_state<'w>(archetype: &'w Archetype) -> Option<Self::State<'w>>

Source§

fn len(state: &Self::State<'_>) -> usize

Source§

fn entity(state: &Self::State<'_>, row: usize) -> Entity

Source§

fn fetch<'w>(state: &Self::State<'w>, row: usize) -> Self::Item<'w>

Source§

impl<T: Component> QuerySpec for Option<&T>

Optional immutable query: matches all archetypes (never filters), returns Some(&T) when the column is present and None when absent.

Source§

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

Source§

type State<'w> = (&'w [Entity], Option<&'w Column<T>>)

Source§

fn matches(_layout: &ArchetypeLayout) -> bool

Source§

fn init_state<'w>(archetype: &'w Archetype) -> Option<Self::State<'w>>

Source§

fn len(state: &Self::State<'_>) -> usize

Source§

fn entity(state: &Self::State<'_>, row: usize) -> Entity

Source§

fn fetch<'w>(state: &Self::State<'w>, row: usize) -> Self::Item<'w>

Implementors§