Trait Fetch

Source
pub trait Fetch<'w>: for<'q> FetchItem<'q> {
    type Prepared: for<'x> PreparedFetch<'x, Item = <Self as FetchItem<'x>>::Item> + 'w;

    const MUTABLE: bool;

    // Required methods
    fn prepare(&'w self, data: FetchPrepareData<'w>) -> Option<Self::Prepared>;
    fn filter_arch(&self, data: FetchAccessData<'_>) -> bool;
    fn access(&self, data: FetchAccessData<'_>, dst: &mut Vec<Access>);
    fn describe(&self, f: &mut Formatter<'_>) -> Result;

    // Provided methods
    fn searcher(&self, _searcher: &mut ArchetypeSearcher) { ... }
    fn by_ref(&self) -> RefFetch<'_, Self>
       where Self: Sized { ... }
}
Expand description

A fetch describes a retrieval of data from the world and archetypes during a query.

A fetch is prepared, wherein borrows are acquired and a PreparedFetch is returned, which is used to provide the query with values.

The PreparedFetch can in turn control the ranges of slots which are requested by the query, e.g; filtering changed components

Required Associated Constants§

Source

const MUTABLE: bool

true if the fetch mutates any component and thus needs a change event

Required Associated Types§

Source

type Prepared: for<'x> PreparedFetch<'x, Item = <Self as FetchItem<'x>>::Item> + 'w

The prepared version of the fetch

Required Methods§

Source

fn prepare(&'w self, data: FetchPrepareData<'w>) -> Option<Self::Prepared>

Prepares the fetch for an archetype by acquiring borrows.

Returns None if the archetype does not match.

Source

fn filter_arch(&self, data: FetchAccessData<'_>) -> bool

Returns true if the archetype matches the fetch

Source

fn access(&self, data: FetchAccessData<'_>, dst: &mut Vec<Access>)

Returns which components and how will be accessed for an archetype.

Source

fn describe(&self, f: &mut Formatter<'_>) -> Result

Describes the fetch in a human-readable fashion

Provided Methods§

Source

fn searcher(&self, _searcher: &mut ArchetypeSearcher)

Returns the required component for the fetch.

This is used for the query to determine which archetypes to visit

Source

fn by_ref(&self) -> RefFetch<'_, Self>
where Self: Sized,

Convert the fetch to a reference type which works with HRTB

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<'a, 'w, F> Fetch<'w> for &'a F
where F: Fetch<'w>, 'a: 'w,

Source§

const MUTABLE: bool = F::MUTABLE

Source§

type Prepared = <F as Fetch<'w>>::Prepared

Source§

fn prepare(&'w self, data: FetchPrepareData<'w>) -> Option<Self::Prepared>

Source§

fn filter_arch(&self, data: FetchAccessData<'_>) -> bool

Source§

fn access(&self, data: FetchAccessData<'_>, dst: &mut Vec<Access>)

Source§

fn describe(&self, f: &mut Formatter<'_>) -> Result

Source§

fn searcher(&self, searcher: &mut ArchetypeSearcher)

Source§

impl<'w> Fetch<'w> for bool

Source§

const MUTABLE: bool = false

Source§

type Prepared = bool

Source§

fn prepare(&'w self, _: FetchPrepareData<'_>) -> Option<Self::Prepared>

Source§

fn filter_arch(&self, _: FetchAccessData<'_>) -> bool

Source§

fn describe(&self, f: &mut Formatter<'_>) -> Result

Source§

fn access(&self, _: FetchAccessData<'_>, _: &mut Vec<Access>)

Source§

impl<'w> Fetch<'w> for ()

Source§

const MUTABLE: bool = false

Source§

type Prepared = ()

Source§

fn prepare(&self, _: FetchPrepareData<'w>) -> Option<Self::Prepared>

Source§

fn filter_arch(&self, _: FetchAccessData<'_>) -> bool

Source§

fn describe(&self, f: &mut Formatter<'_>) -> Result

Source§

fn access(&self, _: FetchAccessData<'_>, _: &mut Vec<Access>)

Source§

impl<'w, A> Fetch<'w> for (A,)
where A: Fetch<'w>,

Source§

const MUTABLE: bool = A::MUTABLE

Source§

type Prepared = (<A as Fetch<'w>>::Prepared,)

Source§

fn prepare(&'w self, data: FetchPrepareData<'w>) -> Option<Self::Prepared>

Source§

fn filter_arch(&self, data: FetchAccessData<'_>) -> bool

Source§

fn describe(&self, f: &mut Formatter<'_>) -> Result

Source§

fn access(&self, data: FetchAccessData<'_>, dst: &mut Vec<Access>)

Source§

fn searcher(&self, searcher: &mut ArchetypeSearcher)

Source§

impl<'w, A, B> Fetch<'w> for (A, B)
where A: Fetch<'w>, B: Fetch<'w>,

Source§

const MUTABLE: bool

Source§

type Prepared = (<A as Fetch<'w>>::Prepared, <B as Fetch<'w>>::Prepared)

Source§

fn prepare(&'w self, data: FetchPrepareData<'w>) -> Option<Self::Prepared>

Source§

fn filter_arch(&self, data: FetchAccessData<'_>) -> bool

Source§

fn describe(&self, f: &mut Formatter<'_>) -> Result

Source§

fn access(&self, data: FetchAccessData<'_>, dst: &mut Vec<Access>)

Source§

fn searcher(&self, searcher: &mut ArchetypeSearcher)

Source§

impl<'w, A, B, C> Fetch<'w> for (A, B, C)
where A: Fetch<'w>, B: Fetch<'w>, C: Fetch<'w>,

Source§

const MUTABLE: bool

Source§

type Prepared = (<A as Fetch<'w>>::Prepared, <B as Fetch<'w>>::Prepared, <C as Fetch<'w>>::Prepared)

Source§

fn prepare(&'w self, data: FetchPrepareData<'w>) -> Option<Self::Prepared>

Source§

fn filter_arch(&self, data: FetchAccessData<'_>) -> bool

Source§

fn describe(&self, f: &mut Formatter<'_>) -> Result

Source§

fn access(&self, data: FetchAccessData<'_>, dst: &mut Vec<Access>)

Source§

fn searcher(&self, searcher: &mut ArchetypeSearcher)

Source§

impl<'w, A, B, C, D> Fetch<'w> for (A, B, C, D)
where A: Fetch<'w>, B: Fetch<'w>, C: Fetch<'w>, D: Fetch<'w>,

Source§

const MUTABLE: bool

Source§

type Prepared = (<A as Fetch<'w>>::Prepared, <B as Fetch<'w>>::Prepared, <C as Fetch<'w>>::Prepared, <D as Fetch<'w>>::Prepared)

Source§

fn prepare(&'w self, data: FetchPrepareData<'w>) -> Option<Self::Prepared>

Source§

fn filter_arch(&self, data: FetchAccessData<'_>) -> bool

Source§

fn describe(&self, f: &mut Formatter<'_>) -> Result

Source§

fn access(&self, data: FetchAccessData<'_>, dst: &mut Vec<Access>)

Source§

fn searcher(&self, searcher: &mut ArchetypeSearcher)

Source§

impl<'w, A, B, C, D, E> Fetch<'w> for (A, B, C, D, E)
where A: Fetch<'w>, B: Fetch<'w>, C: Fetch<'w>, D: Fetch<'w>, E: Fetch<'w>,

Source§

const MUTABLE: bool

Source§

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

Source§

fn prepare(&'w self, data: FetchPrepareData<'w>) -> Option<Self::Prepared>

Source§

fn filter_arch(&self, data: FetchAccessData<'_>) -> bool

Source§

fn describe(&self, f: &mut Formatter<'_>) -> Result

Source§

fn access(&self, data: FetchAccessData<'_>, dst: &mut Vec<Access>)

Source§

fn searcher(&self, searcher: &mut ArchetypeSearcher)

Source§

impl<'w, A, B, C, D, E, F> Fetch<'w> for (A, B, C, D, E, F)
where A: Fetch<'w>, B: Fetch<'w>, C: Fetch<'w>, D: Fetch<'w>, E: Fetch<'w>, F: Fetch<'w>,

Source§

const MUTABLE: bool

Source§

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

Source§

fn prepare(&'w self, data: FetchPrepareData<'w>) -> Option<Self::Prepared>

Source§

fn filter_arch(&self, data: FetchAccessData<'_>) -> bool

Source§

fn describe(&self, f: &mut Formatter<'_>) -> Result

Source§

fn access(&self, data: FetchAccessData<'_>, dst: &mut Vec<Access>)

Source§

fn searcher(&self, searcher: &mut ArchetypeSearcher)

Source§

impl<'w, A, B, C, D, E, F, H> Fetch<'w> for (A, B, C, D, E, F, H)
where A: Fetch<'w>, B: Fetch<'w>, C: Fetch<'w>, D: Fetch<'w>, E: Fetch<'w>, F: Fetch<'w>, H: Fetch<'w>,

Source§

const MUTABLE: bool

Source§

type Prepared = (<A as Fetch<'w>>::Prepared, <B as Fetch<'w>>::Prepared, <C as Fetch<'w>>::Prepared, <D as Fetch<'w>>::Prepared, <E as Fetch<'w>>::Prepared, <F as Fetch<'w>>::Prepared, <H as Fetch<'w>>::Prepared)

Source§

fn prepare(&'w self, data: FetchPrepareData<'w>) -> Option<Self::Prepared>

Source§

fn filter_arch(&self, data: FetchAccessData<'_>) -> bool

Source§

fn describe(&self, f: &mut Formatter<'_>) -> Result

Source§

fn access(&self, data: FetchAccessData<'_>, dst: &mut Vec<Access>)

Source§

fn searcher(&self, searcher: &mut ArchetypeSearcher)

Source§

impl<'w, A, B, C, D, E, F, H, I> Fetch<'w> for (A, B, C, D, E, F, H, I)
where A: Fetch<'w>, B: Fetch<'w>, C: Fetch<'w>, D: Fetch<'w>, E: Fetch<'w>, F: Fetch<'w>, H: Fetch<'w>, I: Fetch<'w>,

Source§

const MUTABLE: bool

Source§

type Prepared = (<A as Fetch<'w>>::Prepared, <B as Fetch<'w>>::Prepared, <C as Fetch<'w>>::Prepared, <D as Fetch<'w>>::Prepared, <E as Fetch<'w>>::Prepared, <F as Fetch<'w>>::Prepared, <H as Fetch<'w>>::Prepared, <I as Fetch<'w>>::Prepared)

Source§

fn prepare(&'w self, data: FetchPrepareData<'w>) -> Option<Self::Prepared>

Source§

fn filter_arch(&self, data: FetchAccessData<'_>) -> bool

Source§

fn describe(&self, f: &mut Formatter<'_>) -> Result

Source§

fn access(&self, data: FetchAccessData<'_>, dst: &mut Vec<Access>)

Source§

fn searcher(&self, searcher: &mut ArchetypeSearcher)

Source§

impl<'w, A, B, C, D, E, F, H, I, J> Fetch<'w> for (A, B, C, D, E, F, H, I, J)
where A: Fetch<'w>, B: Fetch<'w>, C: Fetch<'w>, D: Fetch<'w>, E: Fetch<'w>, F: Fetch<'w>, H: Fetch<'w>, I: Fetch<'w>, J: Fetch<'w>,

Source§

const MUTABLE: bool

Source§

type Prepared = (<A as Fetch<'w>>::Prepared, <B as Fetch<'w>>::Prepared, <C as Fetch<'w>>::Prepared, <D as Fetch<'w>>::Prepared, <E as Fetch<'w>>::Prepared, <F as Fetch<'w>>::Prepared, <H as Fetch<'w>>::Prepared, <I as Fetch<'w>>::Prepared, <J as Fetch<'w>>::Prepared)

Source§

fn prepare(&'w self, data: FetchPrepareData<'w>) -> Option<Self::Prepared>

Source§

fn filter_arch(&self, data: FetchAccessData<'_>) -> bool

Source§

fn describe(&self, f: &mut Formatter<'_>) -> Result

Source§

fn access(&self, data: FetchAccessData<'_>, dst: &mut Vec<Access>)

Source§

fn searcher(&self, searcher: &mut ArchetypeSearcher)

Implementors§

Source§

impl<'a> Fetch<'a> for Nothing

Source§

impl<'a> Fetch<'a> for With

Source§

impl<'a> Fetch<'a> for WithoutRelation

Source§

impl<'a, 'w, F> Fetch<'w> for RefFetch<'a, F>
where F: Fetch<'w>,

Source§

const MUTABLE: bool = F::MUTABLE

Source§

type Prepared = <F as Fetch<'w>>::Prepared

Source§

impl<'w> Fetch<'w> for Slice

Source§

impl<'w> Fetch<'w> for Entity

Source§

const MUTABLE: bool = false

Source§

type Prepared = PreparedEntity

Source§

impl<'w> Fetch<'w> for All

Source§

impl<'w> Fetch<'w> for BatchSize

Source§

impl<'w> Fetch<'w> for WithRelation

Source§

impl<'w> Fetch<'w> for Without

Source§

impl<'w> Fetch<'w> for EntityIds

Source§

const MUTABLE: bool = false

Source§

type Prepared = ReadEntities<'w>

Source§

impl<'w> Fetch<'w> for EntityRefs

Source§

const MUTABLE: bool = false

Source§

type Prepared = PreparedEntityRef<'w>

Source§

impl<'w, A> Fetch<'w> for Or<(A,)>
where A: Fetch<'w>,

Source§

const MUTABLE: bool = A::MUTABLE

Source§

type Prepared = Or<(Option<<A as Fetch<'w>>::Prepared>,)>

Source§

impl<'w, A, B> Fetch<'w> for Or<(A, B)>
where A: Fetch<'w>, B: Fetch<'w>,

Source§

const MUTABLE: bool

Source§

type Prepared = Or<(Option<<A as Fetch<'w>>::Prepared>, Option<<B as Fetch<'w>>::Prepared>)>

Source§

impl<'w, A, B, C> Fetch<'w> for Or<(A, B, C)>
where A: Fetch<'w>, B: Fetch<'w>, C: Fetch<'w>,

Source§

const MUTABLE: bool

Source§

type Prepared = Or<(Option<<A as Fetch<'w>>::Prepared>, Option<<B as Fetch<'w>>::Prepared>, Option<<C as Fetch<'w>>::Prepared>)>

Source§

impl<'w, A, B, C, D> Fetch<'w> for Or<(A, B, C, D)>
where A: Fetch<'w>, B: Fetch<'w>, C: Fetch<'w>, D: Fetch<'w>,

Source§

const MUTABLE: bool

Source§

type Prepared = Or<(Option<<A as Fetch<'w>>::Prepared>, Option<<B as Fetch<'w>>::Prepared>, Option<<C as Fetch<'w>>::Prepared>, Option<<D as Fetch<'w>>::Prepared>)>

Source§

impl<'w, A, B, C, D, E> Fetch<'w> for Or<(A, B, C, D, E)>
where A: Fetch<'w>, B: Fetch<'w>, C: Fetch<'w>, D: Fetch<'w>, E: Fetch<'w>,

Source§

const MUTABLE: bool

Source§

type Prepared = Or<(Option<<A as Fetch<'w>>::Prepared>, Option<<B as Fetch<'w>>::Prepared>, Option<<C as Fetch<'w>>::Prepared>, Option<<D as Fetch<'w>>::Prepared>, Option<<E as Fetch<'w>>::Prepared>)>

Source§

impl<'w, A, B, C, D, E, F> Fetch<'w> for Or<(A, B, C, D, E, F)>
where A: Fetch<'w>, B: Fetch<'w>, C: Fetch<'w>, D: Fetch<'w>, E: Fetch<'w>, F: Fetch<'w>,

Source§

const MUTABLE: bool

Source§

type Prepared = Or<(Option<<A as Fetch<'w>>::Prepared>, Option<<B as Fetch<'w>>::Prepared>, Option<<C as Fetch<'w>>::Prepared>, Option<<D as Fetch<'w>>::Prepared>, Option<<E as Fetch<'w>>::Prepared>, Option<<F as Fetch<'w>>::Prepared>)>

Source§

impl<'w, A, B, C, D, E, F, H> Fetch<'w> for Or<(A, B, C, D, E, F, H)>
where A: Fetch<'w>, B: Fetch<'w>, C: Fetch<'w>, D: Fetch<'w>, E: Fetch<'w>, F: Fetch<'w>, H: Fetch<'w>,

Source§

const MUTABLE: bool

Source§

type Prepared = Or<(Option<<A as Fetch<'w>>::Prepared>, Option<<B as Fetch<'w>>::Prepared>, Option<<C as Fetch<'w>>::Prepared>, Option<<D as Fetch<'w>>::Prepared>, Option<<E as Fetch<'w>>::Prepared>, Option<<F as Fetch<'w>>::Prepared>, Option<<H as Fetch<'w>>::Prepared>)>

Source§

impl<'w, F> Fetch<'w> for Cloned<F>
where F: Fetch<'w> + for<'q> FetchItem<'q>, for<'q> <F as FetchItem<'q>>::Item: Deref, for<'q> <<F as FetchItem<'q>>::Item as Deref>::Target: 'static + Clone,

Source§

const MUTABLE: bool = F::MUTABLE

Source§

type Prepared = Cloned<<F as Fetch<'w>>::Prepared>

Source§

impl<'w, F> Fetch<'w> for Opt<F>
where F: Fetch<'w>,

Source§

const MUTABLE: bool = F::MUTABLE

Source§

type Prepared = PreparedOpt<<F as Fetch<'w>>::Prepared>

Source§

impl<'w, F, M> Fetch<'w> for Cmp<F, M>
where F: Fetch<'w>, F::Prepared: for<'x> RandomFetch<'x>, M: for<'x> CmpMethod<<F::Prepared as PreparedFetch<'x>>::Item> + 'w,

Source§

const MUTABLE: bool = F::MUTABLE

Source§

type Prepared = PreparedCmp<'w, <F as Fetch<'w>>::Prepared, M>

Source§

impl<'w, F, V> Fetch<'w> for AsDeref<F>
where F: Fetch<'w> + for<'q> FetchItem<'q, Item = &'q V>, V: 'static + Deref,

Source§

const MUTABLE: bool = F::MUTABLE

Source§

type Prepared = AsDeref<<F as Fetch<'w>>::Prepared>

Source§

impl<'w, F, V> Fetch<'w> for OptOr<F, V>
where F: Fetch<'w> + for<'q> FetchItem<'q, Item = &'q V>, V: 'static,

Source§

const MUTABLE: bool = F::MUTABLE

Source§

type Prepared = OptOr<Option<<F as Fetch<'w>>::Prepared>, &'w V>

Source§

impl<'w, F: Fetch<'w>> Fetch<'w> for Satisfied<F>

Source§

const MUTABLE: bool = false

Source§

type Prepared = PreparedSatisfied<<F as Fetch<'w>>::Prepared>

Source§

impl<'w, L, R> Fetch<'w> for And<L, R>
where L: Fetch<'w>, R: Fetch<'w>,

Source§

const MUTABLE: bool = false

Source§

type Prepared = And<<L as Fetch<'w>>::Prepared, <R as Fetch<'w>>::Prepared>

Source§

impl<'w, Q, F> Fetch<'w> for Filtered<Q, F>
where Q: Fetch<'w>, F: Fetch<'w>,

Source§

const MUTABLE: bool = Q::MUTABLE

Source§

type Prepared = Filtered<<Q as Fetch<'w>>::Prepared, <F as Fetch<'w>>::Prepared>

Source§

impl<'w, Q, F, T> Fetch<'w> for Map<Q, F>
where Q: Fetch<'w>, F: for<'q> Fn(<Q as FetchItem<'q>>::Item) -> T + 'static, T: 'static,

Source§

const MUTABLE: bool = Q::MUTABLE

Source§

type Prepared = Map<<Q as Fetch<'w>>::Prepared, &'w F>

Source§

impl<'w, Q, S> Fetch<'w> for Source<Q, S>
where Q: Fetch<'w>, Q::Prepared: for<'x> RandomFetch<'x>, S: FetchSource,

Source§

const MUTABLE: bool = Q::MUTABLE

Source§

type Prepared = PreparedSource<'w, <Q as Fetch<'w>>::Prepared>

Source§

impl<'w, T> Fetch<'w> for Component<T>
where T: ComponentValue,

Source§

const MUTABLE: bool = false

Source§

type Prepared = ReadComponent<'w, T>

Source§

impl<'w, T> Fetch<'w> for ChangeFilter<T>
where T: ComponentValue,

Source§

const MUTABLE: bool = false

Source§

type Prepared = PreparedChangeFilter<'w, T>

Source§

impl<'w, T> Fetch<'w> for Not<T>
where T: Fetch<'w>,

Source§

const MUTABLE: bool = true

Source§

type Prepared = Not<Option<<T as Fetch<'w>>::Prepared>>

Source§

impl<'w, T> Fetch<'w> for Union<T>
where T: Fetch<'w>, T::Prepared: UnionFilter,

Source§

const MUTABLE: bool = T::MUTABLE

Source§

type Prepared = Union<<T as Fetch<'w>>::Prepared>

Source§

impl<'w, T> Fetch<'w> for Mutable<T>
where T: ComponentValue,

Source§

const MUTABLE: bool = true

Source§

type Prepared = WriteComponent<'w, T>

Source§

impl<'w, T> Fetch<'w> for NthRelation<T>
where T: ComponentValue,

Source§

const MUTABLE: bool = false

Source§

type Prepared = PreparedNthRelation<'w, T>

Source§

impl<'w, T> Fetch<'w> for Relations<T>
where T: ComponentValue,

Source§

const MUTABLE: bool = false

Source§

type Prepared = PreparedRelations<'w, T>

Source§

impl<'w, T> Fetch<'w> for RelationsMut<T>
where T: ComponentValue,

Source§

const MUTABLE: bool = false

Source§

type Prepared = PreparedRelationsMut<'w, T>

Source§

impl<'w, T: ComponentValue> Fetch<'w> for MaybeMut<T>

Source§

const MUTABLE: bool = false

Source§

type Prepared = PreparedMaybeMut<'w, T>