cyfs_lib/events/
def.rs

1// 用来定义通用的空参数结构体的辅助宏
2#[macro_export]
3macro_rules! declare_event_empty_param {
4    ($name:ident, $category:ident) => {
5        #[derive(Clone)]
6        pub struct $name {}
7
8        impl std::fmt::Display for $name {
9            fn fmt(&self, _f: &mut std::fmt::Formatter) -> std::fmt::Result {
10                Ok(())
11            }
12        }
13
14        impl JsonCodec<Self> for $name {
15            fn encode_json(&self) -> serde_json::Map<String, serde_json::Value> {
16                serde_json::Map::new()
17            }
18
19            fn decode_json(
20                _obj: &serde_json::Map<String, serde_json::Value>,
21            ) -> cyfs_base::BuckyResult<Self> {
22                Ok(Self {})
23            }
24        }
25
26        impl RouterEventCategoryInfo for $name {
27            fn category() -> RouterEventCategory {
28                RouterEventCategory::$category
29            }
30        }
31    };
32}