Trait FetchExt

Source
pub trait FetchExt: Sized {
Show 20 methods // Provided methods fn opt(self) -> Opt<Self> { ... } fn opt_or<V>(self, default: V) -> OptOr<Self, V> where for<'q> Self: for<'w> Fetch<'w> + FetchItem<'q, Item = &'q V> { ... } fn satisfied(self) -> Satisfied<Self> { ... } fn opt_or_default<V>(self) -> OptOr<Self, V> where for<'q> Self: for<'w> Fetch<'w> + FetchItem<'q, Item = &'q V>, V: Default { ... } fn cloned(self) -> Cloned<Self> where Cloned<Self>: for<'x> Fetch<'x> { ... } fn copied(self) -> Copied<Self> where Copied<Self>: for<'x> Fetch<'x> { ... } fn deref(self) -> AsDeref<Self> where AsDeref<Self>: for<'x> Fetch<'x> { ... } fn cmp<F>(self, func: F) -> Cmp<Self, F> where for<'x> Cmp<Self, F>: Fetch<'x> { ... } fn lt<T>(self, other: T) -> Cmp<Self, Less<T>> where for<'x> Cmp<Self, Less<T>>: Fetch<'x> { ... } fn gt<T>(self, other: T) -> Cmp<Self, Greater<T>> where for<'x> Cmp<Self, GreaterEq<T>>: Fetch<'x> { ... } fn ge<T>(self, other: T) -> Cmp<Self, GreaterEq<T>> where for<'x> Cmp<Self, GreaterEq<T>>: Fetch<'x> { ... } fn le<T>(self, other: T) -> Cmp<Self, LessEq<T>> where for<'x> Cmp<Self, LessEq<T>>: Fetch<'x> { ... } fn eq<T>(self, other: T) -> Cmp<Self, Equal<T>> where for<'x> Cmp<Self, Equal<T>>: Fetch<'x> { ... } fn source<S>(self, source: S) -> Source<Self, S> where S: FetchSource { ... } fn relation<T, R>(self, relation: R) -> Source<Self, FromRelation> where R: RelationExt<T>, T: ComponentValue { ... } fn traverse<T, R>(self, relation: R) -> Source<Self, Traverse> where R: RelationExt<T>, T: ComponentValue { ... } fn modified(self) -> <Self as TransformFetch<Modified>>::Output where Self: TransformFetch<Modified> { ... } fn added(self) -> <Self as TransformFetch<Added>>::Output where Self: TransformFetch<Added> { ... } 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 { ... } fn filtered<F>(self, filter: F) -> Filtered<Self, F> where F: for<'x> Fetch<'x> { ... }
}
Expand description

Extension trait for crate::Fetch

Provided Methods§

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.

This allows fetching or joining queries

Source

fn relation<T, R>(self, relation: R) -> Source<Self, FromRelation>
where R: RelationExt<T>, T: ComponentValue,

Follows a relation to resolve the fetch.

This allows you to for example fetch from the parent of an entity.

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

This will attempt to resolve a fetch from and including the source entity, to the roots of the relation.

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.

This is different from E.g; (a().modified(), b().modified()) as it implies only when both a and b are modified in the same iteration, which is seldom useful.

This means will yield any of a or b are modified.

Works with opt, copy, etc constituents.

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.

This is different from E.g; (a().modified(), b().modified()) as it implies only when both a and b are modified in the same iteration, which is seldom useful.

This means will yield any of a or b are modified.

Works with opt, copy, etc constituents.

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

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.

Implementors§

Source§

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