Struct Union

Source
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<T: Clone> Clone for Union<T>

Source§

fn clone(&self) -> Union<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Union<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

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

Source§

const MUTABLE: bool = T::MUTABLE

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

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

The prepared version of the fetch
Source§

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

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
Source§

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

Returns the required component for the fetch. Read more
Source§

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

Convert the fetch to a reference type which works with HRTB
Source§

impl<'q, T> FetchItem<'q> for Union<T>
where T: FetchItem<'q>,

Source§

type Item = <T as FetchItem<'q>>::Item

The item yielded by the prepared fetch
Source§

impl<'q, T> PreparedFetch<'q> for Union<T>
where T: PreparedFetch<'q> + UnionFilter,

Source§

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

Item returned by fetch
Source§

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

Filter the slots to visit Returns the leftmost subslice of slots which should be visited Read more
Source§

unsafe fn create_chunk(&'q mut self, slots: Slice) -> Self::Chunk

Creates a chunk to access a slice of the borrow Read more
Source§

unsafe fn fetch_next(chunk: &mut Self::Chunk) -> Self::Item

Fetch the item from entity at the slot in the prepared storage. Read more
Source§

impl<T> UnionFilter for Union<T>
where T: UnionFilter,

Source§

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.
Source§

unsafe fn filter_union(&mut self, slots: Slice) -> Slice

Safety Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<F> FetchExt for F
where F: for<'x> Fetch<'x>,

Source§

fn opt(self) -> Opt<Self>

Transform the fetch into an optional fetch, yielding Some or None
Source§

fn opt_or<V>(self, default: V) -> OptOr<Self, V>
where for<'q> Self: for<'w> Fetch<'w> + FetchItem<'q, Item = &'q 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>

Returns true if the query is satisfied, without borrowing
Source§

fn opt_or_default<V>(self) -> OptOr<Self, V>
where for<'q> Self: for<'w> Fetch<'w> + FetchItem<'q, Item = &'q V>, V: Default,

Transform the fetch into a fetch which yields the default impl if the fetch is not matched.
Source§

fn cloned(self) -> Cloned<Self>
where Cloned<Self>: for<'x> Fetch<'x>,

Transform this into a cloned fetch
Source§

fn copied(self) -> Copied<Self>
where Copied<Self>: for<'x> Fetch<'x>,

Transform this into a copied fetch
Source§

fn deref(self) -> AsDeref<Self>
where AsDeref<Self>: for<'x> Fetch<'x>,

Dereferences the fetch item
Source§

fn cmp<F>(self, func: F) -> Cmp<Self, F>
where for<'x> Cmp<Self, F>: Fetch<'x>,

Filter any component by predicate.
Source§

fn lt<T>(self, other: T) -> Cmp<Self, Less<T>>
where for<'x> Cmp<Self, Less<T>>: Fetch<'x>,

Filter any component less than other.
Source§

fn gt<T>(self, other: T) -> Cmp<Self, Greater<T>>
where for<'x> Cmp<Self, GreaterEq<T>>: Fetch<'x>,

Filter any component greater than other.
Source§

fn ge<T>(self, other: T) -> Cmp<Self, GreaterEq<T>>
where for<'x> Cmp<Self, GreaterEq<T>>: Fetch<'x>,

Filter any component greater than or equal to other.
Source§

fn le<T>(self, other: T) -> Cmp<Self, LessEq<T>>
where for<'x> Cmp<Self, LessEq<T>>: Fetch<'x>,

Filter any component less than or equal to other.
Source§

fn eq<T>(self, other: T) -> Cmp<Self, Equal<T>>
where for<'x> Cmp<Self, Equal<T>>: Fetch<'x>,

Filter any component equal to other.
Source§

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,

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,

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>>::Output
where 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>>::Output
where Self: TransformFetch<Added>,

Transform the fetch into a fetch where each constituent part tracks and yields for component addition events. Read more
Source§

fn map<F, T>(self, func: F) -> Map<Self, F>
where Self: for<'x> FetchItem<'x>, for<'x> F: Fn(<Self as FetchItem<'x>>::Item) -> T,

Map each item of the query to another type using the provided function.
Source§

fn filtered<F>(self, filter: F) -> Filtered<Self, F>
where F: for<'x> Fetch<'x>,

Filter a fetch with another fetch as predicate
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ComponentValue for T
where T: Send + Sync + 'static,