pub type BoxAgent<S> = Box<dyn DynAgent<State = S>>;Expand description
A type-erased agent over state S.
struct Fixed(&'static str);
impl Agent for Fixed {
type State = ();
async fn run(&self, ctx: &mut RunContext<()>) -> Result<RunOutcome> {
ctx.say(self.0)?;
Ok(RunOutcome::Success)
}
}
let agents: Vec<BoxAgent<()>> = vec![Box::new(Fixed("a")), Box::new(Fixed("b"))];
assert_eq!(agents.len(), 2);Aliased Type§
pub struct BoxAgent<S>(/* private fields */);Trait Implementations§
Source§impl<S: AgentState> Agent for BoxAgent<S>
impl<S: AgentState> Agent for BoxAgent<S>
Source§type State = S
type State = S
The run’s shared state, deserialized from
RunAgentInput::state and published
through RunContext::set_state.Source§async fn run(&self, ctx: &mut RunContext<Self::State>) -> Result<RunOutcome>
async fn run(&self, ctx: &mut RunContext<Self::State>) -> Result<RunOutcome>
Serves one run. Read more