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