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§
Required Associated Types§
Sourcetype Prepared: for<'x> PreparedFetch<'x, Item = <Self as FetchItem<'x>>::Item> + 'w
type Prepared: for<'x> PreparedFetch<'x, Item = <Self as FetchItem<'x>>::Item> + 'w
The prepared version of the fetch
Required Methods§
Sourcefn prepare(&'w self, data: FetchPrepareData<'w>) -> Option<Self::Prepared>
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.
Sourcefn filter_arch(&self, data: FetchAccessData<'_>) -> bool
fn filter_arch(&self, data: FetchAccessData<'_>) -> bool
Returns true if the archetype matches the fetch
Sourcefn access(&self, data: FetchAccessData<'_>, dst: &mut Vec<Access>)
fn access(&self, data: FetchAccessData<'_>, dst: &mut Vec<Access>)
Returns which components and how will be accessed for an archetype.
Provided Methods§
Sourcefn searcher(&self, _searcher: &mut ArchetypeSearcher)
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
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.