Before
parent: tbd commit: e432306
1 | use Future; |
2 | |
3 | use |
4 | , |
5 | , | FfiValueUntyped
6 | , |
7 | FfiValueMut, FfiValueRef, |
8 | ; |
9 | use ; |
10 | |
11 | use crate:: |
12 | , |
13 | , | PluginState
14 | , | State
15 | ; |
16 | |
17 | use RuntimeState; |
18 | |
19 | ; |
20 | |
21 | |
22 | type CallbackFunc = unsafe extern "C" fn |
23 | , |
24 | state: , |
25 | object: , |
26 | ; |
27 | |
28 | |
29 | |
30 | // pub fn new<S, O, OS, T: IntoPluginSettingGetter<S, O, OS>>(callback: T) -> Self { |
31 | // Self { |
32 | // func: T::get_setting, |
33 | // callback_ptr: callback.callback_ptr(), |
34 | // } |
35 | // } |
36 | |
37 | |
38 | |
39 | unsafe extern "C" |
40 | callback_ptr: , |
41 | state: , |
42 | object: , |
43 | ; |
44 | |
45 | |
46 | // unsafe { CallbackPtr::from_raw(self as *const _ as *const ()) } |
47 | todo! |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | Fut: + Send + Sync + 'static, |
54 | S: Clone + Send + Sync + 'static, |
55 | O: GiteratedObject + Send + Sync + 'static, |
56 | OS: Setting + Send + Sync + 'static, |
57 | F: Fn(S, O) -> Fut + Send + Sync + 'static, |
58 | |
59 | unsafe extern "C" |
60 | callback: , |
61 | state: , |
62 | mut object: , |
63 | |
64 | // let _guard = trace_span!( |
65 | // "get_setting handler", |
66 | // object = O::object_name(), |
67 | // setting = OS::name() |
68 | // ) |
69 | // .entered(); |
70 | // let state = unsafe { state.transmute_ref::<S>() }; |
71 | |
72 | // let object = unsafe { object.transmute_owned::<O>() }; |
73 | |
74 | // // Cast the callback ptr to ourselves |
75 | // let callback: *const F = std::mem::transmute(callback.0); |
76 | // let callback = callback.as_ref().unwrap(); |
77 | |
78 | // let state = state.clone(); |
79 | // runtime_state.spawn_future(async move { |
80 | // let result = callback(state, *object).await; |
81 | |
82 | // match result { |
83 | // Ok(success) => unsafe { Ok(NewAnySetting::new(success)) }, |
84 | // Err(err) => match err { |
85 | // OperationError::Operation(_) => todo!(), |
86 | // OperationError::Internal(_) => todo!(), |
87 | // OperationError::Unhandled => todo!(), |
88 | // }, |
89 | // } |
90 | |
91 | todo! |
92 | // }) |
93 | |
94 | |
95 | |
96 | |
97 | unsafe extern "C" |
98 | callback_ptr: , |
99 | state: &PluginState, |
100 | object: , |
101 | setting: Setting, |
102 | ; |
103 | |
104 | |
105 | // unsafe { CallbackPtr::from_raw(self as *const _ as *const ()) } |
106 | todo! |
107 | |
108 | |
109 | |
110 | |
111 | |
112 | Fut: , |
113 | S: Clone, |
114 | O: GiteratedObject, |
115 | OS: Setting, |
116 | F: Fn(S, O, OS) -> Fut, |
117 | |
118 | unsafe extern "C" |
119 | callback: , |
120 | state: &PluginState, |
121 | mut object: , |
122 | _setting: Setting, |
123 | |
124 | // let _guard = trace_span!( |
125 | // "get_setting handler", |
126 | // object = O::object_name(), |
127 | // setting = OS::name() |
128 | // ) |
129 | // .entered(); |
130 | // let _state = unsafe { state.transmute_ref::<S>() }; |
131 | |
132 | // let _object = unsafe { object.transmute_owned::<O>() }; |
133 | |
134 | // // Cast the callback ptr to ourselves |
135 | // let callback: *const F = std::mem::transmute(callback.0); |
136 | // let _callback = callback.as_ref().unwrap(); |
137 | |
138 | // let result = callback(state.clone(), *object); |
139 | |
140 | // match result { |
141 | // Ok(setting) => Ok(NewAnySetting::new(setting)), |
142 | // Err(_) => todo!(), |
143 | // } |
144 | todo! |
145 | |
146 | |
147 | |
148 | ; |
149 | |
150 | |
151 | type CallbackFunc = unsafe extern "C" fn |
152 | &PluginState, |
153 | object: , |
154 | setting_name: &str, |
155 | new_setting: Setting, |
156 | ; |
157 | |
158 | |
159 | |
160 | unsafe extern "C" |
161 | state: &PluginState, |
162 | object: , |
163 | setting_name: &str, |
164 | new_setting: Setting, |
165 | ; |
166 | |
167 | |
168 | |
169 | unsafe extern "C" |
170 | _state: &PluginState, |
171 | _object: , |
172 | _setting_name: &str, |
173 | _new_setting: Setting, |
174 | |
175 | todo! |
176 | |
177 | |
178 | |
179 | // impl SettingChangeCallback { |
180 | // pub fn new<S, O, T: IntoSettingChangeCallback<S, O>>() -> Self { |
181 | // Self { |
182 | // func: T::setting_changed, |
183 | // } |
184 | // } |
185 | // } |
186 |