Skip to main content

GraphOracle

Trait GraphOracle 

Source
pub trait GraphOracle {
    // Required methods
    fn neighbours(&mut self, state: GcRef) -> Result<Vec<GcRef>, Aborted>;
    fn weight(&mut self, from: GcRef, to: GcRef) -> Result<i64, Aborted>;
    fn heuristic(&mut self, state: GcRef) -> Result<i64, Aborted>;
    fn is_goal(&mut self, state: GcRef) -> Result<bool, Aborted>;
    fn retain(&mut self, state: GcRef);
    fn abort(&mut self, kind: FaultKind) -> Aborted;
}
Expand description

What a walk asks about the graph it is walking.

Every method may fault — the closures are arbitrary Praxis code — so every answer is a Result. An Err(Aborted) means a fault is already pending on the context and the walk must stop; it never means “no answer”.

Required Methods§

Source

fn neighbours(&mut self, state: GcRef) -> Result<Vec<GcRef>, Aborted>

The states reachable in one step from state.

Source

fn weight(&mut self, from: GcRef, to: GcRef) -> Result<i64, Aborted>

The cost of the edge from from to to. Only called for a pair the oracle itself reported adjacent.

Source

fn heuristic(&mut self, state: GcRef) -> Result<i64, Aborted>

The estimated remaining cost from state to a goal.

Source

fn is_goal(&mut self, state: GcRef) -> Result<bool, Aborted>

Whether state is a goal.

Source

fn retain(&mut self, state: GcRef)

Keep state alive for the rest of the walk. Called once per state, the moment the walk decides to remember it.

Source

fn abort(&mut self, kind: FaultKind) -> Aborted

Raise kind and stop the walk. The Aborted it returns is the only way a walk reports a fault of its own.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§