Giterated stack changeover, refactor still incomplete
parent: tbd commit: 8d40dfe
1 | |
2 | |
3 | |
4 | use ; |
5 | |
6 | use FutureExt; |
7 | use |
8 | , | OperationError
9 | , | Instance
10 | , |
11 | , |
12 | ; |
13 | |
14 | |
15 | operations: , |
16 | get_object: , |
17 | |
18 | |
19 | |
20 | |
21 | Self |
22 | operations: Vec new, |
23 | get_object: Vec new, |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | O: GiteratedObject + Send + Sync, |
31 | D: + 'static, |
32 | H: + Send + Sync + 'static + Clone, |
33 | > |
34 | &mut self, |
35 | handler: H, |
36 | |
37 | let _operation_name = handler.operation_name .to_string; |
38 | |
39 | let wrapped = new; |
40 | |
41 | self.operations.push; |
42 | |
43 | self |
44 | |
45 | |
46 | |
47 | let closure = |
48 | async move |
49 | if from_str .is_ok |
50 | Ok |
51 | else |
52 | Err |
53 | |
54 | |
55 | .boxed |
56 | ; |
57 | |
58 | let wrapped = new; |
59 | |
60 | self.get_object.push; |
61 | |
62 | self |
63 | |
64 | |
65 | pub async |
66 | &self, |
67 | object: &O, |
68 | _operation_name: &str, |
69 | operation: AnyOperation, |
70 | state: S, |
71 | |
72 | for handler in self.operations.iter |
73 | return match handler |
74 | .handle |
75 | AnyObject, |
76 | operation.clone, |
77 | state.clone, |
78 | |
79 | .await |
80 | |
81 | Ok => Ok, |
82 | Err => Err |
83 | => Operation, | Operation
84 | => Internal, | Internal
85 | => continue, | Unhandled
86 | , |
87 | ; |
88 | |
89 | |
90 | Err |
91 | |
92 | |
93 | pub async |
94 | &self, |
95 | instance: AnyObject, |
96 | request: ObjectRequest, |
97 | state: S, |
98 | |
99 | for handler in self.get_object.iter |
100 | if let Ok = handler |
101 | .handle |
102 | instance.clone, |
103 | AnyOperation, |
104 | state.clone, |
105 | |
106 | .await |
107 | |
108 | return Ok; |
109 | |
110 | |
111 | |
112 | Err |
113 | |
114 | |
115 | |
116 | |
117 | |
118 | O: GiteratedObject, |
119 | D: GiteratedOperation<O>, |
120 | S: Send + Sync + Clone, |
121 | > |
122 | |
123 | ; |
124 | ; |
125 | |
126 | async |
127 | &self, |
128 | object: &O, |
129 | operation: D, |
130 | state: S, |
131 | ; |
132 | |
133 | |
134 | |
135 | |
136 | |
137 | F: FnMut( |
138 | &O, |
139 | D, |
140 | S, |
141 | ) -> |
142 | , |
143 | > + Send |
144 | + Sync |
145 | + Clone, |
146 | O: GiteratedObject + Send + Sync, |
147 | D: + 'static, |
148 | : Send, | Failure
149 | S: Send + Sync + Clone + 'static, |
150 | |
151 | |
152 | operation_name |
153 | |
154 | |
155 | |
156 | object_name |
157 | |
158 | |
159 | async |
160 | &self, |
161 | object: &O, |
162 | operation: D, |
163 | state: S, |
164 | |
165 | self.clone .await |
166 | |
167 | |
168 | |
169 | |
170 | |
171 | dyn Fn( |
172 | AnyObject, |
173 | AnyOperation, |
174 | S, |
175 | ) |
176 | |
177 | + Send |
178 | + Sync, |
179 | >, |
180 | ); |
181 | |
182 | |
183 | |
184 | O: GiteratedObject + Send + Sync, |
185 | D: + 'static, |
186 | F: + Send + Sync + 'static + Clone, |
187 | > |
188 | handler: F, |
189 | |
190 | let handler = new; |
191 | Self |
192 | let handler = handler.clone; |
193 | async move |
194 | let handler = handler.clone; |
195 | let object: O = |
196 | map_err?; | from_object_str .
197 | let operation: D = from_value |
198 | .map_err?; |
199 | |
200 | let result = handler.handle .await; |
201 | result |
202 | .map |
203 | .map_err |
204 | => | Operation
205 | Operation |
206 | |
207 | => Internal, | Internal
208 | => Unhandled, | Unhandled
209 | |
210 | |
211 | .boxed |
212 | |
213 | |
214 | |
215 | async |
216 | &self, |
217 | object: AnyObject, |
218 | operation: AnyOperation, |
219 | state: S, |
220 | |
221 | self.0 .await |
222 | |
223 | |
224 |