Skip to main content

DynAgent

Trait DynAgent 

Source
pub trait DynAgent: Send + Sync {
    type State: AgentState;

    // Required method
    fn run_boxed<'a>(
        &'a self,
        ctx: &'a mut RunContext<Self::State>,
    ) -> Pin<Box<dyn Future<Output = Result<RunOutcome>> + Send + 'a>>;
}
Expand description

The dyn-compatible form of Agent.

Implemented for every Agent, so Box::new(my_agent) as BoxAgent<_> just works. The only difference is one boxed future per run.

Required Associated Types§

Source

type State: AgentState

The run’s shared state — see Agent::State.

Required Methods§

Source

fn run_boxed<'a>( &'a self, ctx: &'a mut RunContext<Self::State>, ) -> Pin<Box<dyn Future<Output = Result<RunOutcome>> + Send + 'a>>

Serves one run, boxing the future so the trait stays object-safe.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<A: Agent> DynAgent for A

Source§

type State = <A as Agent>::State