pub struct Union<T>(pub T);
Expand description
Unionized the slot-level filter of two fetches, but requires the individual fetches to still match.
This allows the filters to return fetch items side by side like the wrapped fetch would, since all constituent fetches are satisfied, but not necessarily all their entities.
This is most useful for change queries, where you care about about any change, but still require the entity to have all the components, and have them returned despite not all having changed.
For this to implement Fetch
, T::Prepared
must implement UnionFilter
.
Tuple Fields§
§0: T
Trait Implementations§
Source§impl<'w, T> Fetch<'w> for Union<T>
impl<'w, T> Fetch<'w> for Union<T>
Source§const MUTABLE: bool = T::MUTABLE
const MUTABLE: bool = T::MUTABLE
true if the fetch mutates any component and thus needs a change event
Source§fn 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. Read more
Source§fn filter_arch(&self, data: FetchAccessData<'_>) -> bool
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>)
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
fn describe(&self, f: &mut Formatter<'_>) -> Result
Describes the fetch in a human-readable fashion
Source§fn searcher(&self, _searcher: &mut ArchetypeSearcher)
fn searcher(&self, _searcher: &mut ArchetypeSearcher)
Returns the required component for the fetch. Read more
Source§impl<'q, T> PreparedFetch<'q> for Union<T>where
T: PreparedFetch<'q> + UnionFilter,
impl<'q, T> PreparedFetch<'q> for Union<T>where
T: PreparedFetch<'q> + UnionFilter,
Source§const HAS_FILTER: bool = T::HAS_UNION_FILTER
const HAS_FILTER: bool = T::HAS_UNION_FILTER
Indicates if the fetch will provide any filtering of slots. Read more
Source§type Item = <T as PreparedFetch<'q>>::Item
type Item = <T as PreparedFetch<'q>>::Item
Item returned by fetch
Source§type Chunk = <T as PreparedFetch<'q>>::Chunk
type Chunk = <T as PreparedFetch<'q>>::Chunk
A chunk accessing a disjoint set of the borrow sequentially
Source§unsafe fn filter_slots(&mut self, slots: Slice) -> Slice
unsafe fn filter_slots(&mut self, slots: Slice) -> Slice
Filter the slots to visit
Returns the leftmost subslice of
slots
which should be visited Read moreSource§impl<T> UnionFilter for Union<T>where
T: UnionFilter,
impl<T> UnionFilter for Union<T>where
T: UnionFilter,
Source§const HAS_UNION_FILTER: bool = T::HAS_UNION_FILTER
const HAS_UNION_FILTER: bool = T::HAS_UNION_FILTER
The union may not have the same filter behavior as a normal filter as sub-filters
are combined using or instead of and. This means any non-filter will cause the
whole tuple to always yield.
Auto Trait Implementations§
impl<T> Freeze for Union<T>where
T: Freeze,
impl<T> RefUnwindSafe for Union<T>where
T: RefUnwindSafe,
impl<T> Send for Union<T>where
T: Send,
impl<T> Sync for Union<T>where
T: Sync,
impl<T> Unpin for Union<T>where
T: Unpin,
impl<T> UnwindSafe for Union<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F> FetchExt for Fwhere
F: for<'x> Fetch<'x>,
impl<F> FetchExt for Fwhere
F: for<'x> Fetch<'x>,
Source§fn opt_or<V>(self, default: V) -> OptOr<Self, V>
fn opt_or<V>(self, default: V) -> OptOr<Self, V>
Transform the fetch into a fetch with a provided default.
This is useful for default values such as scale or velocity which may
not exist for every entity.
Source§fn satisfied(self) -> Satisfied<Self>
fn satisfied(self) -> Satisfied<Self>
Returns true if the query is satisfied, without borrowing
Source§fn opt_or_default<V>(self) -> OptOr<Self, V>
fn opt_or_default<V>(self) -> OptOr<Self, V>
Transform the fetch into a fetch which yields the default impl if the
fetch is not matched.
Source§fn copied(self) -> Copied<Self>where
Copied<Self>: for<'x> Fetch<'x>,
fn copied(self) -> Copied<Self>where
Copied<Self>: for<'x> Fetch<'x>,
Transform this into a copied fetch
Source§fn ge<T>(self, other: T) -> Cmp<Self, GreaterEq<T>>
fn ge<T>(self, other: T) -> Cmp<Self, GreaterEq<T>>
Filter any component greater than or equal to
other
.Source§fn le<T>(self, other: T) -> Cmp<Self, LessEq<T>>
fn le<T>(self, other: T) -> Cmp<Self, LessEq<T>>
Filter any component less than or equal to
other
.Source§fn source<S>(self, source: S) -> Source<Self, S>where
S: FetchSource,
fn source<S>(self, source: S) -> Source<Self, S>where
S: FetchSource,
Set the source entity for the fetch. Read more
Source§fn relation<T, R>(self, relation: R) -> Source<Self, FromRelation>where
R: RelationExt<T>,
T: ComponentValue,
fn relation<T, R>(self, relation: R) -> Source<Self, FromRelation>where
R: RelationExt<T>,
T: ComponentValue,
Follows a relation to resolve the fetch. Read more
Source§fn traverse<T, R>(self, relation: R) -> Source<Self, Traverse>where
R: RelationExt<T>,
T: ComponentValue,
fn traverse<T, R>(self, relation: R) -> Source<Self, Traverse>where
R: RelationExt<T>,
T: ComponentValue,
Traverse the edges of a relation recursively to find the first entity which matches the fetch Read more
Source§fn modified(self) -> <Self as TransformFetch<Modified>>::Outputwhere
Self: TransformFetch<Modified>,
fn modified(self) -> <Self as TransformFetch<Modified>>::Outputwhere
Self: TransformFetch<Modified>,
Transform the fetch into a fetch where each constituent part tracks and yields for
modification events. Read more
Source§fn added(self) -> <Self as TransformFetch<Added>>::Outputwhere
Self: TransformFetch<Added>,
fn added(self) -> <Self as TransformFetch<Added>>::Outputwhere
Self: TransformFetch<Added>,
Transform the fetch into a fetch where each constituent part tracks and yields for
component addition events. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more