`[feature/plugins]` Some plugin work?
parent: tbd commit: 10a447b
1 | use ; |
2 | |
3 | use Error; |
4 | use ; |
5 | use |
6 | , |
7 | , | Instance
8 | , | GiteratedObject
9 | , | GiteratedOperation
10 | ; |
11 | use |
12 | , |
13 | AnyFailure, AnyObject, AnyOperation, AnySuccess, |
14 | ; |
15 | use ; |
16 | use TcpStream; |
17 | use ; |
18 | |
19 | use crate::; |
20 | |
21 | pub async |
22 | _state: ProtocolState, |
23 | object: NetworkedObject, |
24 | operation: NetworkedOperation, |
25 | runtime: RuntimeHandle, |
26 | |
27 | trace!; |
28 | |
29 | runtime |
30 | .handle_serialized |
31 | .await |
32 | |
33 | |
34 | |
35 | ; |
36 | |
37 | |
38 | type Err = ; |
39 | |
40 | |
41 | Ok |
42 | |
43 | |
44 | |
45 | |
46 | |
47 | f.write_str |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | "networked_object" |
54 | |
55 | |
56 | |
57 | todo! |
58 | |
59 | |
60 | |
61 | todo! |
62 | |
63 | |
64 | |
65 | |
66 | |
67 | pub name: String, |
68 | pub payload: , |
69 | |
70 | |
71 | |
72 | |
73 | Self |
74 | |
75 | |
76 | |
77 | |
78 | type Success = ; |
79 | |
80 | type Failure = ; |
81 | |
82 | |
83 | "networked_operation" |
84 | |
85 | |
86 | |
87 | /// Handler which will attempt to resolve any operation that doesn't resolve locally |
88 | /// against a remote instance. |
89 | pub async |
90 | state: ProtocolState, |
91 | object: AnyObject, |
92 | operation: AnyOperation, |
93 | _runtime: RuntimeHandle, |
94 | |
95 | // if object.is::<NetworkedObject>() { |
96 | // return Err(OperationError::Unhandled); |
97 | // } |
98 | // trace!( |
99 | // "Try handling object operation {}::{} with remote", |
100 | // object.kind(), |
101 | // operation.kind().operation_name |
102 | // ); |
103 | // TODO: |
104 | // Ideally we support pass-through on object types that aren't used locally. |
105 | // For now, we aren't worrying about that. |
106 | let object_meta = object.vtable .clone; |
107 | |
108 | let operation_meta = operation.vtable .clone; |
109 | |
110 | // trace!( |
111 | // "Serializing with {}::{}", |
112 | // operation.kind().object_name, |
113 | // operation.kind().operation_name |
114 | // ); |
115 | |
116 | let object_home_uri = unsafe ; |
117 | |
118 | if let Some = state.home_uri |
119 | if &home_uri == object_home_uri.as_ref |
120 | // This isn't a remote request, requests aren't supposed to hit this layer |
121 | // if they're not remote. |
122 | // warn!("Try handling object operation {}::{}, resolved object home uri as local home uri. This is a bug.", object.kind(), |
123 | // operation.kind().operation_name); |
124 | |
125 | return Err; |
126 | |
127 | |
128 | |
129 | // trace!( |
130 | // "Handling object operation {}::{} sending payload", |
131 | // object.kind(), |
132 | // operation.kind().operation_name |
133 | // ); |
134 | |
135 | let object = NetworkedObject; |
136 | |
137 | let payload = unsafe .unwrap; |
138 | let payload = Vec from; |
139 | |
140 | let operation = new; |
141 | |
142 | // let authenticated = Authenticated::new(object, operation); |
143 | |
144 | let message = GiteratedMessage |
145 | object, |
146 | operation: operation_name .to_string, |
147 | payload: operation, |
148 | ; |
149 | |
150 | let authenticated = new; |
151 | |
152 | let mut socket: = connect_to |
153 | & from_str .unwrap, |
154 | &Some, |
155 | |
156 | .await |
157 | .unwrap; |
158 | |
159 | // TODO AUTH |
160 | |
161 | let result: = |
162 | send_expect .await; |
163 | |
164 | match result |
165 | Ok => |
166 | let success = unsafe .unwrap; |
167 | |
168 | Ok |
169 | |
170 | Err => Err |
171 | => | Operation
172 | let failure = unsafe .unwrap; |
173 | |
174 | Operation |
175 | |
176 | => Internal, | Internal
177 | => Unhandled, | Unhandled
178 | , |
179 | |
180 | |
181 | |
182 | type Socket = ; |
183 | |
184 | async |
185 | instance: &Instance, |
186 | |
187 | socket_addr: & , |
188 | |
189 | if let Some = socket_addr |
190 | info! |
191 | "Connecting to {}", |
192 | format! |
193 | ; |
194 | |
195 | let = |
196 | connect_async .await?; |
197 | |
198 | info!; |
199 | |
200 | Ok |
201 | else |
202 | info! |
203 | "Connecting to {}", |
204 | format! |
205 | ; |
206 | |
207 | let = |
208 | connect_async .await?; |
209 | |
210 | info!; |
211 | |
212 | Ok |
213 | |
214 | |
215 | |
216 | async |
217 | socket: &mut Socket, |
218 | message: , |
219 | |
220 | let payload = serialize .unwrap; |
221 | |
222 | socket.send .await.unwrap; |
223 | |
224 | while let Some = socket.next .await |
225 | let payload = match message.unwrap |
226 | => payload, | Binary
227 | |
228 | _ => |
229 | continue; |
230 | |
231 | ; |
232 | |
233 | let raw_result = |
234 | |
235 | .map_err?; |
236 | |
237 | trace! |
238 | "Received response for networked operation {}::{}.", |
239 | , | object_name
240 | operation_name |
241 | ; |
242 | |
243 | return match raw_result |
244 | Ok => Ok, |
245 | Err => Err |
246 | => | Operation
247 | Operation |
248 | |
249 | => Internal, | Internal
250 | => Unhandled, | Unhandled
251 | , |
252 | ; |
253 | |
254 | |
255 | panic! |
256 | |
257 |