ObjectHierarchy

Trait ObjectHierarchy 

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

Source

fn parent(&self) -> Option<Self::Rebind<Any>>

Returns the parent of this object, if it exists.

Source

fn children(&self) -> impl Iterator<Item = Self::Rebind<Any>>

Iterates over all children of this object.

Source

fn ancestors(&self) -> impl Iterator<Item = Self::Rebind<Any>>

Iterates over all ancestors of this object.

Source

fn descendants_wide(&self) -> impl Iterator<Item = Self::Rebind<Any>>

Iterates over all descendants of this object in breadth-first order.

Source

fn descendants_deep(&self) -> impl Iterator<Item = Self::Rebind<Any>>

Iterates over all descendants of this object in depth-first order.

Source

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§

Source

fn root(&self) -> Self::Rebind<Any>

Returns the root of this object’s hierarchy.

Source

fn is_root(&self) -> bool

Returns true if this object is the root of its hierarchy.

Returns true if this object has the same root as another.

Source

fn is_child(&self) -> bool

Returns true if this object is a child of another.

Source

fn is_child_of(&self, entity: Entity) -> bool

Returns true if this object is a child of the given Entity.

Source

fn has_children(&self) -> bool

Returns true if this object has any children.

Source

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.

Source

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.

Source

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.

Source

fn self_and_ancestors(&self) -> impl Iterator<Item = Self::Rebind<Any>>

Iterates over this object, followed by all of its ancestors.

Source

fn is_ancestor_of<U: Kind>(&self, other: &impl ObjectHierarchy<U>) -> bool
where Self::Rebind<Any>: ObjectHierarchy<Any>,

Returns true if this object is an ancestor of another.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn self_and_descendants_wide(&self) -> impl Iterator<Item = Self::Rebind<Any>>

Iterates over this object and all its descendants in breadth-first order.

Source

fn self_and_descendants_deep(&self) -> impl Iterator<Item = Self::Rebind<Any>>

Iterates over this object and all its descendants in depth-first order.

Source

fn is_descendant_of(&self, entity: Entity) -> bool
where Self::Rebind<Any>: ObjectHierarchy<Any>,

Returns true if this object is a descendant of the given entity.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn find_descendant_of_kind_deep<'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 (depth-first order) which matches the given Kind, if it exists.

Source

fn path(&self) -> String

Returns the path to this object.

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<T: Kind> ObjectHierarchy<T> for Object<'_, '_, '_, T>

Source§

impl<T: Kind> ObjectHierarchy<T> for ObjectRef<'_, '_, '_, T>

Source§

impl<T: Kind> ObjectHierarchy<T> for ObjectWorldRef<'_, T>