simple_task/
handler.rs

1use serde_json::Value;
2use std::collections::HashMap;
3use std::fmt::Debug;
4use std::future::Future;
5use std::pin::Pin;
6use std::sync::Arc;
7
8
9pub type HandlerFn = Arc<
10    dyn Fn(Value) -> Pin<Box<dyn Future<Output = anyhow::Result<Value>> + Send + Sync>>
11        + Send
12        + Sync,
13>;
14
15pub struct Handler {
16    pub name: String,
17    pub func: HandlerFn,
18}
19
20impl Debug for Handler {
21    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22        f.debug_struct("Handler")
23            .field("name", &self.name)
24            .field("func", &"<...>")
25            .finish()
26    }
27}
28
29pub type HandlerMap = HashMap<String, Arc<Handler>>;