1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::fmt::Debug;
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
#[async_trait]
pub trait Job: Debug + Send + Sync + 'static {
type Output: Clone + Serialize + for<'de> Deserialize<'de> + Send + Sync + 'static;
async fn execute(&mut self) -> anyhow::Result<Self::Output>;
}
pub trait Keyed<Key>: Job
where
Key: Clone + std::hash::Hash + Eq + Send + Sync + Debug + 'static,
{
fn key(&self) -> Key;
}
#[async_trait]
pub trait Executable: Send + Sync + Debug {
async fn execute(&mut self);
}