Skip to main content

RoutingFunction

Trait RoutingFunction 

Source
pub trait RoutingFunction: Send + Sync {
    // Required method
    fn route<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        state: &'life1 AgentState,
        config: &'life2 GraphConfig,
    ) -> Pin<Box<dyn Future<Output = Result<RouterOutput>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn semantic_digest(&self) -> String { ... }
}
Expand description

Determines which node to visit next based on current state.

Required Methods§

Source

fn route<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, state: &'life1 AgentState, config: &'life2 GraphConfig, ) -> Pin<Box<dyn Future<Output = Result<RouterOutput>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Returns routing decision. Return RouterOutput::Next(None) to end execution.

Provided Methods§

Source

fn semantic_digest(&self) -> String

Stable caller-visible identity for routing semantics. Implementations should override this when the route behavior depends on configuration.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<F> RoutingFunction for FnRouter<F>
where F: Fn(&AgentState, &GraphConfig) -> Pin<Box<dyn Future<Output = Result<RouterOutput>> + Send>> + Send + Sync,