bevy_ecs::traversal

Trait Traversal

Source
pub trait Traversal: ReadOnlyQueryData {
    // Required method
    fn traverse(item: Self::Item<'_>) -> Option<Entity>;
}
Expand description

A component that can point to another entity, and which can be used to define a path through the ECS.

Traversals are used to specify the direction of event propagation in observers. The default query is ().

Infinite loops are possible, and are not checked for. While looping can be desirable in some contexts (for example, an observer that triggers itself multiple times before stopping), following an infinite traversal loop without an eventual exit will can your application to hang. Each implementer of Traversal for documenting possible looping behavior, and consumers of those implementations are responsible for avoiding infinite loops in their code.

Required Methods§

Source

fn traverse(item: Self::Item<'_>) -> Option<Entity>

Returns the next entity to visit.

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.

Implementations on Foreign Types§

Source§

impl Traversal for ()

Source§

fn traverse(_: Self::Item<'_>) -> Option<Entity>

Implementors§