cyfs_lib/events/
processor.rs1use super::category::*;
2use super::request::*;
3use cyfs_base::*;
4use cyfs_util::*;
5
6use std::sync::Arc;
7
8#[async_trait::async_trait]
9pub trait RouterEventProcessor<REQ, RESP>: Send + Sync
10where
11 REQ: Send + Sync + 'static + JsonCodec<REQ> + std::fmt::Display,
12 RESP: Send + Sync + 'static + JsonCodec<RESP> + std::fmt::Display,
13 RouterEventRequest<REQ>: RouterEventCategoryInfo,
14{
15 async fn add_event(
16 &self,
17 id: &str,
18 index: i32,
19 routine: Box<
20 dyn EventListenerAsyncRoutine<RouterEventRequest<REQ>, RouterEventResponse<RESP>>,
21 >,
22 ) -> BuckyResult<()>;
23
24 async fn remove_event(&self, id: &str) -> BuckyResult<bool>;
25}
26
27pub trait RouterEventManagerProcessor: Send + Sync {
28 fn test_event(&self) -> &dyn RouterEventProcessor<TestEventRequest, TestEventResponse>;
29 fn zone_role_changed_event(&self) -> &dyn RouterEventProcessor<ZoneRoleChangedEventRequest, ZoneRoleChangedEventResponse>;
30}
31
32pub type RouterEventManagerProcessorRef = Arc<Box<dyn RouterEventManagerProcessor>>;