crb_superagent/mission/
mod.rs1pub mod async_fn;
2pub mod reporting;
3pub mod runtime;
4pub mod sync_fn;
5
6pub use runtime::RunMission;
7
8use anyhow::Result;
9use async_trait::async_trait;
10use crb_agent::{Agent, Context};
11
12pub trait Goal: Send + 'static {}
13
14impl<T> Goal for T where Self: Send + 'static {}
15
16#[async_trait]
17pub trait Mission: Agent {
18    type Goal: Goal;
19
20    async fn deliver(self, ctx: &mut Context<Self>) -> Option<Self::Goal>;
21}
22
23pub trait Observer<M: Mission>: Send {
24    fn check(&mut self, goal: &M::Goal) -> Result<()>;
25}
26
27pub trait Runnable: Mission {
28    fn run(self) -> RunMission<Self>;
29}
30
31impl<M: Mission> Runnable for M
32where
33    Self::Context: Default,
34{
35    fn run(self) -> RunMission<Self> {
36        RunMission::new(self)
37    }
38}