Trait Walker

Source
pub trait Walker<'graph>
where Self: Sized,
{ type Graph: Graph; type Context: Clone + 'static; // Required methods fn next_element( &mut self, graph: &'graph Self::Graph, ) -> Option<ElementId<Self::Graph>>; fn ctx(&self) -> &Self::Context; fn ctx_mut(&mut self) -> &mut Self::Context; }
Expand description

A trait that defines the basic behavior of a graph walker.

The Walker trait is the foundation for traversing and exploring graphs in the graph-api-lib crate. It defines the core methods that all walkers must implement, such as next_element to retrieve the next vertex or edge in the graph, and ctx to access the walker’s internal context.

Implementors of this trait are responsible for defining the specific graph representation they work with (via the Graph associated type) and the internal state they need to track during the walk (via the Context associated type).

Required Associated Types§

Source

type Graph: Graph

The graph that the traversal is applied to.

Source

type Context: Clone + 'static

The current context of the walker, this allows users to collect data as they traverse a graph.

Required Methods§

Source

fn next_element( &mut self, graph: &'graph Self::Graph, ) -> Option<ElementId<Self::Graph>>

Return the next element in the traversal.

Source

fn ctx(&self) -> &Self::Context

Returns the current context of the walker.

Source

fn ctx_mut(&mut self) -> &mut Self::Context

Returns the mutable current context of the walker.

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§