More progress :)
parent: tbd commit: 92c3f32
1 | use |
2 | , | OperationError
3 | , | GiteratedObject
4 | , |
5 | ; |
6 | |
7 | use crate:: |
8 | , |
9 | , |
10 | , | OperationVTable
11 | AnyFailure, AnyObject, AnyOperation, AnySuccess, FFIBox, |
12 | ; |
13 | |
14 | use ; |
15 | |
16 | use ; |
17 | |
18 | |
19 | |
20 | pub callback_ptr: CallbackPtr, |
21 | pub func: unsafe extern "C" fn |
22 | CallbackPtr, |
23 | &RuntimeState, |
24 | &PluginState, |
25 | object: AnyObject, |
26 | operation: AnyOperation, |
27 | |
28 | , |
29 | |
30 | |
31 | |
32 | |
33 | S, |
34 | O: GiteratedObject, |
35 | D: , |
36 | A, |
37 | T: , |
38 | > |
39 | handler: T, |
40 | |
41 | OperationHandlerCallback |
42 | func: handle, |
43 | callback_ptr: callback_ptr, |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | unsafe extern "C" |
50 | callback_ptr: CallbackPtr, |
51 | runtime_state: &RuntimeState, |
52 | state: &PluginState, |
53 | object: AnyObject, |
54 | operation: AnyOperation, |
55 | ; |
56 | ; |
57 | |
58 | |
59 | |
60 | |
61 | Fut: + Send + Sync, |
62 | F: Fn(S, O, D) -> Fut + Send + Sync + 'static, |
63 | S: Clone + Debug + Send + Sync + 'static, |
64 | O: Debug + GiteratedObject + 'static, |
65 | D: Debug + + 'static, |
66 | |
67 | unsafe extern "C" |
68 | callback: CallbackPtr, |
69 | runtime_state: &RuntimeState, |
70 | state: &PluginState, |
71 | mut object: AnyObject, |
72 | mut operation: AnyOperation, |
73 | |
74 | let _guard = trace_span! |
75 | "operation handler", |
76 | object = , |
77 | operation = |
78 | |
79 | .entered; |
80 | let state = unsafe ; |
81 | |
82 | // Since this is Rust code, we know that the AnyObject and AnyOperation are just boxes |
83 | let object = unsafe ; |
84 | let operation = unsafe ; |
85 | |
86 | // Cast the callback ptr to ourselves |
87 | let callback: *const F = transmute; |
88 | let callback = callback.as_ref .unwrap; |
89 | |
90 | let state = state.clone; |
91 | runtime_state.spawn_future |
92 | let result = callback .await; |
93 | |
94 | match result |
95 | Ok => unsafe |
96 | Ok |
97 | untyped, | from_box .
98 | , |
99 | |
100 | , |
101 | Err => match err |
102 | => todo!, | Operation
103 | => todo!, | Internal
104 | => todo!, | Unhandled
105 | , |
106 | |
107 | |
108 | |
109 | |
110 | |
111 | unsafe |
112 | |
113 | |
114 | |
115 | |
116 | |
117 | Fut: , |
118 | F: Fn(S, O, D, A1) -> Fut, |
119 | S: Clone + Debug, |
120 | O: Debug + GiteratedObject, |
121 | D: Debug + , |
122 | |
123 | unsafe extern "C" |
124 | _callback_ptr: CallbackPtr, |
125 | _runtime_state: &RuntimeState, |
126 | _state: &PluginState, |
127 | _object: AnyObject, |
128 | _operation: AnyOperation, |
129 | |
130 | todo! |
131 | |
132 | |
133 | |
134 | todo! |
135 | |
136 | |
137 | |
138 | |
139 | |
140 | Fut: , |
141 | F: Fn(S, O, D, A1, A2) -> Fut, |
142 | S: Clone + Debug, |
143 | O: Debug + GiteratedObject, |
144 | D: Debug + , |
145 | |
146 | unsafe extern "C" |
147 | _callback_ptr: CallbackPtr, |
148 | _runtime_state: &RuntimeState, |
149 | _state: &PluginState, |
150 | _object: AnyObject, |
151 | _operation: AnyOperation, |
152 | |
153 | todo! |
154 | |
155 | |
156 | |
157 | todo! |
158 | |
159 | |
160 | |
161 | |
162 | |
163 | operation_state: &OperationState, |
164 | runtime_state: &RuntimeState, |
165 | object: &O, |
166 | operation: &D, |
167 | ; |
168 | |
169 | |
170 | |
171 | |
172 | _operation_state: &OperationState, |
173 | runtime_state: &RuntimeState, |
174 | _object: &O, |
175 | _operation: &D, |
176 | |
177 | Ok |
178 | |
179 | |
180 | |
181 | |
182 | |
183 | T: , |
184 | |
185 | |
186 | operation_state: &OperationState, |
187 | runtime_state: &RuntimeState, |
188 | object: &O, |
189 | operation: &D, |
190 | |
191 | Ok |
192 | |
193 | |
194 |