cyfs_lib/rmeta/
processor.rs1use super::def::*;
2use super::output_request::*;
3use crate::{RequestSourceInfo, GlobalStateCategory};
4use cyfs_base::*;
5
6use std::sync::Arc;
7
8#[async_trait::async_trait]
9pub trait GlobalStateMetaOutputProcessor: Sync + Send + 'static {
10 async fn add_access(
11 &self,
12 req: GlobalStateMetaAddAccessOutputRequest,
13 ) -> BuckyResult<GlobalStateMetaAddAccessOutputResponse>;
14
15 async fn remove_access(
16 &self,
17 req: GlobalStateMetaRemoveAccessOutputRequest,
18 ) -> BuckyResult<GlobalStateMetaRemoveAccessOutputResponse>;
19
20 async fn clear_access(
21 &self,
22 req: GlobalStateMetaClearAccessOutputRequest,
23 ) -> BuckyResult<GlobalStateMetaClearAccessOutputResponse>;
24
25 async fn add_link(
26 &self,
27 req: GlobalStateMetaAddLinkOutputRequest,
28 ) -> BuckyResult<GlobalStateMetaAddLinkOutputResponse>;
29
30 async fn remove_link(
31 &self,
32 req: GlobalStateMetaRemoveLinkOutputRequest,
33 ) -> BuckyResult<GlobalStateMetaRemoveLinkOutputResponse>;
34
35 async fn clear_link(
36 &self,
37 req: GlobalStateMetaClearLinkOutputRequest,
38 ) -> BuckyResult<GlobalStateMetaClearLinkOutputResponse>;
39
40 async fn add_object_meta(
42 &self,
43 req: GlobalStateMetaAddObjectMetaOutputRequest,
44 ) -> BuckyResult<GlobalStateMetaAddObjectMetaOutputResponse>;
45
46 async fn remove_object_meta(
47 &self,
48 req: GlobalStateMetaRemoveObjectMetaOutputRequest,
49 ) -> BuckyResult<GlobalStateMetaRemoveObjectMetaOutputResponse>;
50
51 async fn clear_object_meta(
52 &self,
53 req: GlobalStateMetaClearObjectMetaOutputRequest,
54 ) -> BuckyResult<GlobalStateMetaClearObjectMetaOutputResponse>;
55
56 async fn add_path_config(
58 &self,
59 req: GlobalStateMetaAddPathConfigOutputRequest,
60 ) -> BuckyResult<GlobalStateMetaAddPathConfigOutputResponse>;
61
62 async fn remove_path_config(
63 &self,
64 req: GlobalStateMetaRemovePathConfigOutputRequest,
65 ) -> BuckyResult<GlobalStateMetaRemovePathConfigOutputResponse>;
66
67 async fn clear_path_config(
68 &self,
69 req: GlobalStateMetaClearPathConfigOutputRequest,
70 ) -> BuckyResult<GlobalStateMetaClearPathConfigOutputResponse>;
71}
72
73pub type GlobalStateMetaOutputProcessorRef = Arc<Box<dyn GlobalStateMetaOutputProcessor>>;
74
75#[async_trait::async_trait]
76pub trait GlobalStateMetaRawProcessor: Send + Sync {
77 async fn add_access(&self, item: GlobalStatePathAccessItem) -> BuckyResult<bool>;
79
80 async fn remove_access(
81 &self,
82 item: GlobalStatePathAccessItem,
83 ) -> BuckyResult<Option<GlobalStatePathAccessItem>>;
84
85 async fn clear_access(&self) -> BuckyResult<usize>;
86
87 fn check_access<'d, 'a, 'b>(
88 &self,
89 req: GlobalStateAccessRequest<'d, 'a, 'b>,
90 ) -> BuckyResult<()>;
91
92 async fn add_link(
94 &self,
95 source: &str,
96 target: &str,
97 ) -> BuckyResult<bool>;
98
99 async fn remove_link(&self, source: &str) -> BuckyResult<Option<GlobalStatePathLinkItem>>;
100
101 async fn clear_link(&self) -> BuckyResult<usize>;
102
103 fn resolve_link(&self, source: &str) -> BuckyResult<Option<String>>;
104
105 async fn add_object_meta(&self, item: GlobalStateObjectMetaItem) -> BuckyResult<bool>;
107
108 async fn remove_object_meta(
109 &self,
110 item: GlobalStateObjectMetaItem,
111 ) -> BuckyResult<Option<GlobalStateObjectMetaItem>>;
112
113 async fn clear_object_meta(&self) -> BuckyResult<usize>;
114
115 fn check_object_access(
116 &self,
117 target_dec_id: &ObjectId,
118 object_data: &dyn ObjectSelectorDataProvider,
119 source: &RequestSourceInfo,
120 permissions: AccessPermissions,
121 ) -> BuckyResult<Option<()>>;
122
123 fn query_object_meta(
124 &self,
125 object_data: &dyn ObjectSelectorDataProvider,
126 ) -> Option<GlobalStateObjectMetaConfigItemValue>;
127
128 async fn add_path_config(&self, item: GlobalStatePathConfigItem) -> BuckyResult<bool>;
130
131 async fn remove_path_config(
132 &self,
133 item: GlobalStatePathConfigItem,
134 ) -> BuckyResult<Option<GlobalStatePathConfigItem>>;
135 async fn clear_path_config(&self) -> BuckyResult<usize>;
136
137 fn query_path_config(&self, path: &str) -> Option<GlobalStatePathConfigItemValue>;
138}
139
140pub type GlobalStateMetaRawProcessorRef = Arc<Box<dyn GlobalStateMetaRawProcessor>>;
141
142
143#[async_trait::async_trait]
144pub trait GlobalStateMetaManagerRawProcessor: Send + Sync {
145 async fn get_global_state_meta(
146 &self,
147 dec_id: &ObjectId,
148 category: GlobalStateCategory,
149 auto_create: bool,
150 ) -> BuckyResult<Option<GlobalStateMetaRawProcessorRef>>;
151}
152
153pub type GlobalStateMetaManagerRawProcessorRef = Arc<Box<dyn GlobalStateMetaManagerRawProcessor>>;