pub trait ObjectHierarchy<T: Kind = Any>: ObjectRebind<T> + ObjectName {
Show 36 methods
// Required methods
fn parent(&self) -> Option<Self::Rebind<Any>>;
fn children(&self) -> impl Iterator<Item = Self::Rebind<Any>>;
fn ancestors(&self) -> impl Iterator<Item = Self::Rebind<Any>>;
fn descendants_wide(&self) -> impl Iterator<Item = Self::Rebind<Any>>;
fn descendants_deep(&self) -> impl Iterator<Item = Self::Rebind<Any>>;
fn find_by_path(&self, path: impl AsRef<str>) -> Option<Self::Rebind<Any>>;
// Provided methods
fn root(&self) -> Self::Rebind<Any> { ... }
fn is_root(&self) -> bool { ... }
fn is_related_to<U: Kind>(&self, other: &impl ObjectHierarchy<U>) -> bool { ... }
fn is_child(&self) -> bool { ... }
fn is_child_of(&self, entity: Entity) -> bool { ... }
fn has_children(&self) -> bool { ... }
fn query_children<'a, Q: QueryData, F: QueryFilter>(
&'a self,
query: &'a Query<'_, '_, Q, F>,
) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a { ... }
fn children_of_kind<'w, 's, 'a, U: Kind>(
&'a self,
objects: &'a Objects<'w, 's, U>,
) -> impl Iterator<Item = Object<'w, 's, 'a, U>> + 'a { ... }
fn find_child_of_kind<'w, 's, 'a, U: Kind>(
&self,
objects: &'a Objects<'w, 's, U>,
) -> Option<Object<'w, 's, 'a, U>> { ... }
fn self_and_ancestors(&self) -> impl Iterator<Item = Self::Rebind<Any>> { ... }
fn is_ancestor_of<U: Kind>(&self, other: &impl ObjectHierarchy<U>) -> bool
where Self::Rebind<Any>: ObjectHierarchy<Any> { ... }
fn query_ancestors<'a, Q: QueryData, F: QueryFilter>(
&'a self,
query: &'a Query<'_, '_, Q, F>,
) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a { ... }
fn query_self_and_ancestors<'a, Q: QueryData, F: QueryFilter>(
&'a self,
query: &'a Query<'_, '_, Q, F>,
) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a { ... }
fn ancestors_of_kind<'w, 's, 'a, U: Kind>(
&'a self,
objects: &'a Objects<'w, 's, U>,
) -> impl Iterator<Item = Object<'w, 's, 'a, U>> { ... }
fn self_and_ancestors_of_kind<'w, 's, 'a, U: Kind>(
&'a self,
objects: &'a Objects<'w, 's, U>,
) -> impl Iterator<Item = Object<'w, 's, 'a, U>> { ... }
fn find_ancestor_of_kind<'w, 's, 'a, U: Kind>(
&self,
objects: &'a Objects<'w, 's, U>,
) -> Option<Object<'w, 's, 'a, U>> { ... }
fn self_and_descendants_wide(
&self,
) -> impl Iterator<Item = Self::Rebind<Any>> { ... }
fn self_and_descendants_deep(
&self,
) -> impl Iterator<Item = Self::Rebind<Any>> { ... }
fn is_descendant_of(&self, entity: Entity) -> bool
where Self::Rebind<Any>: ObjectHierarchy<Any> { ... }
fn descendants_of_kind_wide<'w, 's, 'a, U: Kind>(
&'a self,
objects: &'a Objects<'w, 's, U>,
) -> impl Iterator<Item = Object<'w, 's, 'a, U>> { ... }
fn descendants_of_kind_deep<'w, 's, 'a, U: Kind>(
&'a self,
objects: &'a Objects<'w, 's, U>,
) -> impl Iterator<Item = Object<'w, 's, 'a, U>> { ... }
fn self_and_descendants_of_kind_wide<'w, 's, 'a, U: Kind>(
&'a self,
objects: &'a Objects<'w, 's, U>,
) -> impl Iterator<Item = Object<'w, 's, 'a, U>> { ... }
fn self_and_descendants_of_kind_deep<'w, 's, 'a, U: Kind>(
&'a self,
objects: &'a Objects<'w, 's, U>,
) -> impl Iterator<Item = Object<'w, 's, 'a, U>> { ... }
fn query_descendants_wide<'a, Q: QueryData, F: QueryFilter>(
&'a self,
query: &'a Query<'_, '_, Q, F>,
) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a { ... }
fn query_descendants_deep<'a, Q: QueryData, F: QueryFilter>(
&'a self,
query: &'a Query<'_, '_, Q, F>,
) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a { ... }
fn query_self_and_descendants_wide<'a, Q: QueryData, F: QueryFilter>(
&'a self,
query: &'a Query<'_, '_, Q, F>,
) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a { ... }
fn query_self_and_descendants_deep<'a, Q: QueryData>(
&'a self,
query: &'a Query<'_, '_, Q>,
) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a { ... }
fn find_descendant_of_kind_wide<'w, 's, 'a, U: Kind>(
&self,
objects: &'a Objects<'w, 's, U>,
) -> Option<Object<'w, 's, 'a, U>> { ... }
fn find_descendant_of_kind_deep<'w, 's, 'a, U: Kind>(
&self,
objects: &'a Objects<'w, 's, U>,
) -> Option<Object<'w, 's, 'a, U>> { ... }
fn path(&self) -> String { ... }
}Expand description
Object methods related to hierarchy traversal.
These methods are available to any Object<T> or ObjectRef<T> type.
Required Methods§
Sourcefn children(&self) -> impl Iterator<Item = Self::Rebind<Any>>
fn children(&self) -> impl Iterator<Item = Self::Rebind<Any>>
Iterates over all children of this object.
Sourcefn ancestors(&self) -> impl Iterator<Item = Self::Rebind<Any>>
fn ancestors(&self) -> impl Iterator<Item = Self::Rebind<Any>>
Iterates over all ancestors of this object.
Sourcefn descendants_wide(&self) -> impl Iterator<Item = Self::Rebind<Any>>
fn descendants_wide(&self) -> impl Iterator<Item = Self::Rebind<Any>>
Iterates over all descendants of this object in breadth-first order.
Sourcefn descendants_deep(&self) -> impl Iterator<Item = Self::Rebind<Any>>
fn descendants_deep(&self) -> impl Iterator<Item = Self::Rebind<Any>>
Iterates over all descendants of this object in depth-first order.
Sourcefn find_by_path(&self, path: impl AsRef<str>) -> Option<Self::Rebind<Any>>
fn find_by_path(&self, path: impl AsRef<str>) -> Option<Self::Rebind<Any>>
Attempts to find an object by its path, relative to this one.
§Usage
An Object Path is a string of object names separated by slashes which represents the path to an object within a hierarchy.
In additional to object names, the path may contain the following special characters:
.represents this object...represents the parent object.*represents any child object.
Note that this method of object search is relatively slow, and should be reserved for when performance is not the top priority, such as during initialization or prototyping.
Instead, prefer to use Component to tag your entities and Query them instead, if possible.
§Safety
This method is somewhat experimental with plans for future expansion. Please report any bugs you encounter or features you’d like.
Provided Methods§
Returns true if this object has the same root as another.
Sourcefn is_child_of(&self, entity: Entity) -> bool
fn is_child_of(&self, entity: Entity) -> bool
Returns true if this object is a child of the given Entity.
Sourcefn has_children(&self) -> bool
fn has_children(&self) -> bool
Returns true if this object has any children.
Sourcefn query_children<'a, Q: QueryData, F: QueryFilter>(
&'a self,
query: &'a Query<'_, '_, Q, F>,
) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a
fn query_children<'a, Q: QueryData, F: QueryFilter>( &'a self, query: &'a Query<'_, '_, Q, F>, ) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a
Iterates over all children of this object which match the given Query.
Sourcefn children_of_kind<'w, 's, 'a, U: Kind>(
&'a self,
objects: &'a Objects<'w, 's, U>,
) -> impl Iterator<Item = Object<'w, 's, 'a, U>> + 'a
fn children_of_kind<'w, 's, 'a, U: Kind>( &'a self, objects: &'a Objects<'w, 's, U>, ) -> impl Iterator<Item = Object<'w, 's, 'a, U>> + 'a
Iterates over all children of this object which match the given Kind.
Sourcefn find_child_of_kind<'w, 's, 'a, U: Kind>(
&self,
objects: &'a Objects<'w, 's, U>,
) -> Option<Object<'w, 's, 'a, U>>
fn find_child_of_kind<'w, 's, 'a, U: Kind>( &self, objects: &'a Objects<'w, 's, U>, ) -> Option<Object<'w, 's, 'a, U>>
Returns the first child of this object which matches the given kind, if it exists.
Sourcefn self_and_ancestors(&self) -> impl Iterator<Item = Self::Rebind<Any>>
fn self_and_ancestors(&self) -> impl Iterator<Item = Self::Rebind<Any>>
Iterates over this object, followed by all of its ancestors.
Sourcefn is_ancestor_of<U: Kind>(&self, other: &impl ObjectHierarchy<U>) -> bool
fn is_ancestor_of<U: Kind>(&self, other: &impl ObjectHierarchy<U>) -> bool
Returns true if this object is an ancestor of another.
Sourcefn query_ancestors<'a, Q: QueryData, F: QueryFilter>(
&'a self,
query: &'a Query<'_, '_, Q, F>,
) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a
fn query_ancestors<'a, Q: QueryData, F: QueryFilter>( &'a self, query: &'a Query<'_, '_, Q, F>, ) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a
Iterates over all ancestors of this object which match the given Query.
Sourcefn query_self_and_ancestors<'a, Q: QueryData, F: QueryFilter>(
&'a self,
query: &'a Query<'_, '_, Q, F>,
) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a
fn query_self_and_ancestors<'a, Q: QueryData, F: QueryFilter>( &'a self, query: &'a Query<'_, '_, Q, F>, ) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a
Iterates over this object, followed by all its ancestors which match the given Query.
Sourcefn ancestors_of_kind<'w, 's, 'a, U: Kind>(
&'a self,
objects: &'a Objects<'w, 's, U>,
) -> impl Iterator<Item = Object<'w, 's, 'a, U>>
fn ancestors_of_kind<'w, 's, 'a, U: Kind>( &'a self, objects: &'a Objects<'w, 's, U>, ) -> impl Iterator<Item = Object<'w, 's, 'a, U>>
Iterates over all ancestors of this object which match the given Kind.
Sourcefn self_and_ancestors_of_kind<'w, 's, 'a, U: Kind>(
&'a self,
objects: &'a Objects<'w, 's, U>,
) -> impl Iterator<Item = Object<'w, 's, 'a, U>>
fn self_and_ancestors_of_kind<'w, 's, 'a, U: Kind>( &'a self, objects: &'a Objects<'w, 's, U>, ) -> impl Iterator<Item = Object<'w, 's, 'a, U>>
Iterates over this object, followed by all its ancestors which match the given Kind.
Sourcefn find_ancestor_of_kind<'w, 's, 'a, U: Kind>(
&self,
objects: &'a Objects<'w, 's, U>,
) -> Option<Object<'w, 's, 'a, U>>
fn find_ancestor_of_kind<'w, 's, 'a, U: Kind>( &self, objects: &'a Objects<'w, 's, U>, ) -> Option<Object<'w, 's, 'a, U>>
Returns the first ancestor of this object which matches the given Kind, if it exists.
Sourcefn self_and_descendants_wide(&self) -> impl Iterator<Item = Self::Rebind<Any>>
fn self_and_descendants_wide(&self) -> impl Iterator<Item = Self::Rebind<Any>>
Iterates over this object and all its descendants in breadth-first order.
Sourcefn self_and_descendants_deep(&self) -> impl Iterator<Item = Self::Rebind<Any>>
fn self_and_descendants_deep(&self) -> impl Iterator<Item = Self::Rebind<Any>>
Iterates over this object and all its descendants in depth-first order.
Sourcefn is_descendant_of(&self, entity: Entity) -> bool
fn is_descendant_of(&self, entity: Entity) -> bool
Returns true if this object is a descendant of the given entity.
Sourcefn descendants_of_kind_wide<'w, 's, 'a, U: Kind>(
&'a self,
objects: &'a Objects<'w, 's, U>,
) -> impl Iterator<Item = Object<'w, 's, 'a, U>>
fn descendants_of_kind_wide<'w, 's, 'a, U: Kind>( &'a self, objects: &'a Objects<'w, 's, U>, ) -> impl Iterator<Item = Object<'w, 's, 'a, U>>
Iterates over all descendants of this object which match the given Kind in breadth-first order.
Sourcefn descendants_of_kind_deep<'w, 's, 'a, U: Kind>(
&'a self,
objects: &'a Objects<'w, 's, U>,
) -> impl Iterator<Item = Object<'w, 's, 'a, U>>
fn descendants_of_kind_deep<'w, 's, 'a, U: Kind>( &'a self, objects: &'a Objects<'w, 's, U>, ) -> impl Iterator<Item = Object<'w, 's, 'a, U>>
Iterates over all descendants of this object which match the given Kind in depth-first order.
Sourcefn self_and_descendants_of_kind_wide<'w, 's, 'a, U: Kind>(
&'a self,
objects: &'a Objects<'w, 's, U>,
) -> impl Iterator<Item = Object<'w, 's, 'a, U>>
fn self_and_descendants_of_kind_wide<'w, 's, 'a, U: Kind>( &'a self, objects: &'a Objects<'w, 's, U>, ) -> impl Iterator<Item = Object<'w, 's, 'a, U>>
Iterates over this object, followed by all its descendants which match the given Kind in breadth-first order.
Sourcefn self_and_descendants_of_kind_deep<'w, 's, 'a, U: Kind>(
&'a self,
objects: &'a Objects<'w, 's, U>,
) -> impl Iterator<Item = Object<'w, 's, 'a, U>>
fn self_and_descendants_of_kind_deep<'w, 's, 'a, U: Kind>( &'a self, objects: &'a Objects<'w, 's, U>, ) -> impl Iterator<Item = Object<'w, 's, 'a, U>>
Iterates over this object, followed by all its descendants which match the given Kind in depth-first order.
Sourcefn query_descendants_wide<'a, Q: QueryData, F: QueryFilter>(
&'a self,
query: &'a Query<'_, '_, Q, F>,
) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a
fn query_descendants_wide<'a, Q: QueryData, F: QueryFilter>( &'a self, query: &'a Query<'_, '_, Q, F>, ) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a
Iterates over all descendants of this object which match the given Query in breadth-first order.
Sourcefn query_descendants_deep<'a, Q: QueryData, F: QueryFilter>(
&'a self,
query: &'a Query<'_, '_, Q, F>,
) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a
fn query_descendants_deep<'a, Q: QueryData, F: QueryFilter>( &'a self, query: &'a Query<'_, '_, Q, F>, ) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a
Iterates over all descendants of this object which match the given Kind in depth-first order.
Sourcefn query_self_and_descendants_wide<'a, Q: QueryData, F: QueryFilter>(
&'a self,
query: &'a Query<'_, '_, Q, F>,
) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a
fn query_self_and_descendants_wide<'a, Q: QueryData, F: QueryFilter>( &'a self, query: &'a Query<'_, '_, Q, F>, ) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a
Iterates over this object, followed by all its descendants which match the given Query in breadth-first order.
Sourcefn query_self_and_descendants_deep<'a, Q: QueryData>(
&'a self,
query: &'a Query<'_, '_, Q>,
) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a
fn query_self_and_descendants_deep<'a, Q: QueryData>( &'a self, query: &'a Query<'_, '_, Q>, ) -> impl Iterator<Item = QueryItem<'a, 'a, Q::ReadOnly>> + 'a
Iterates over this object, followed by all its descendants which match the given Query in depth-first order.
Sourcefn find_descendant_of_kind_wide<'w, 's, 'a, U: Kind>(
&self,
objects: &'a Objects<'w, 's, U>,
) -> Option<Object<'w, 's, 'a, U>>
fn find_descendant_of_kind_wide<'w, 's, 'a, U: Kind>( &self, objects: &'a Objects<'w, 's, U>, ) -> Option<Object<'w, 's, 'a, U>>
Returns the first descendant of this object (breadth-first order) which matches the given Kind, if it exists.
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.