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