crb_parallel/
concurrent.rs1use anyhow::Result;
2use async_trait::async_trait;
3
4#[async_trait]
5pub trait Concurrent {
6 type Context;
7 type Input;
8 type Output;
9
10 async fn initialize(&mut self, _ctx: &mut Self::Context) -> Result<()> {
11 Ok(())
12 }
13
14 async fn map(&mut self, ctx: &mut Self::Context) -> Option<Self::Input>;
15
16 async fn task(input: Self::Input) -> Self::Output;
17
18 async fn reduce(&mut self, output: Self::Output, ctx: &mut Self::Context);
19
20 async fn finalize(&mut self, _ctx: &mut Self::Context) -> Result<()> {
21 Ok(())
22 }
23}