Merge pull request #786 from TheBlueMatt/2021-02-chansigner-util
[rust-lightning] / lightning-c-bindings / src / c_types / derived.rs
1 #[repr(C)]
2 pub struct CVec_SpendableOutputDescriptorZ {
3         pub data: *mut crate::chain::keysinterface::SpendableOutputDescriptor,
4         pub datalen: usize
5 }
6 impl CVec_SpendableOutputDescriptorZ {
7         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::chain::keysinterface::SpendableOutputDescriptor> {
8                 if self.datalen == 0 { return Vec::new(); }
9                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
10                 self.data = std::ptr::null_mut();
11                 self.datalen = 0;
12                 ret
13         }
14         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::chain::keysinterface::SpendableOutputDescriptor] {
15                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
16         }
17 }
18 impl From<Vec<crate::chain::keysinterface::SpendableOutputDescriptor>> for CVec_SpendableOutputDescriptorZ {
19         fn from(v: Vec<crate::chain::keysinterface::SpendableOutputDescriptor>) -> Self {
20                 let datalen = v.len();
21                 let data = Box::into_raw(v.into_boxed_slice());
22                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
23         }
24 }
25 #[no_mangle]
26 pub extern "C" fn CVec_SpendableOutputDescriptorZ_free(_res: CVec_SpendableOutputDescriptorZ) { }
27 impl Drop for CVec_SpendableOutputDescriptorZ {
28         fn drop(&mut self) {
29                 if self.datalen == 0 { return; }
30                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
31         }
32 }
33 impl Clone for CVec_SpendableOutputDescriptorZ {
34         fn clone(&self) -> Self {
35                 let mut res = Vec::new();
36                 if self.datalen == 0 { return Self::from(res); }
37                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
38                 Self::from(res)
39         }
40 }
41 #[repr(C)]
42 pub struct CVec_MessageSendEventZ {
43         pub data: *mut crate::util::events::MessageSendEvent,
44         pub datalen: usize
45 }
46 impl CVec_MessageSendEventZ {
47         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::util::events::MessageSendEvent> {
48                 if self.datalen == 0 { return Vec::new(); }
49                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
50                 self.data = std::ptr::null_mut();
51                 self.datalen = 0;
52                 ret
53         }
54         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::util::events::MessageSendEvent] {
55                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
56         }
57 }
58 impl From<Vec<crate::util::events::MessageSendEvent>> for CVec_MessageSendEventZ {
59         fn from(v: Vec<crate::util::events::MessageSendEvent>) -> Self {
60                 let datalen = v.len();
61                 let data = Box::into_raw(v.into_boxed_slice());
62                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
63         }
64 }
65 #[no_mangle]
66 pub extern "C" fn CVec_MessageSendEventZ_free(_res: CVec_MessageSendEventZ) { }
67 impl Drop for CVec_MessageSendEventZ {
68         fn drop(&mut self) {
69                 if self.datalen == 0 { return; }
70                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
71         }
72 }
73 impl Clone for CVec_MessageSendEventZ {
74         fn clone(&self) -> Self {
75                 let mut res = Vec::new();
76                 if self.datalen == 0 { return Self::from(res); }
77                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
78                 Self::from(res)
79         }
80 }
81 #[repr(C)]
82 pub struct CVec_EventZ {
83         pub data: *mut crate::util::events::Event,
84         pub datalen: usize
85 }
86 impl CVec_EventZ {
87         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::util::events::Event> {
88                 if self.datalen == 0 { return Vec::new(); }
89                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
90                 self.data = std::ptr::null_mut();
91                 self.datalen = 0;
92                 ret
93         }
94         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::util::events::Event] {
95                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
96         }
97 }
98 impl From<Vec<crate::util::events::Event>> for CVec_EventZ {
99         fn from(v: Vec<crate::util::events::Event>) -> Self {
100                 let datalen = v.len();
101                 let data = Box::into_raw(v.into_boxed_slice());
102                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
103         }
104 }
105 #[no_mangle]
106 pub extern "C" fn CVec_EventZ_free(_res: CVec_EventZ) { }
107 impl Drop for CVec_EventZ {
108         fn drop(&mut self) {
109                 if self.datalen == 0 { return; }
110                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
111         }
112 }
113 impl Clone for CVec_EventZ {
114         fn clone(&self) -> Self {
115                 let mut res = Vec::new();
116                 if self.datalen == 0 { return Self::from(res); }
117                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
118                 Self::from(res)
119         }
120 }
121 #[repr(C)]
122 pub struct C2Tuple_usizeTransactionZ {
123         pub a: usize,
124         pub b: crate::c_types::Transaction,
125 }
126 impl From<(usize, crate::c_types::Transaction)> for C2Tuple_usizeTransactionZ {
127         fn from (tup: (usize, crate::c_types::Transaction)) -> Self {
128                 Self {
129                         a: tup.0,
130                         b: tup.1,
131                 }
132         }
133 }
134 impl C2Tuple_usizeTransactionZ {
135         #[allow(unused)] pub(crate) fn to_rust(mut self) -> (usize, crate::c_types::Transaction) {
136                 (self.a, self.b)
137         }
138 }
139 #[no_mangle]
140 pub extern "C" fn C2Tuple_usizeTransactionZ_new(a: usize, b: crate::c_types::Transaction) -> C2Tuple_usizeTransactionZ {
141         C2Tuple_usizeTransactionZ { a, b, }
142 }
143
144 #[no_mangle]
145 pub extern "C" fn C2Tuple_usizeTransactionZ_free(_res: C2Tuple_usizeTransactionZ) { }
146 #[repr(C)]
147 pub struct CVec_C2Tuple_usizeTransactionZZ {
148         pub data: *mut crate::c_types::derived::C2Tuple_usizeTransactionZ,
149         pub datalen: usize
150 }
151 impl CVec_C2Tuple_usizeTransactionZZ {
152         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::C2Tuple_usizeTransactionZ> {
153                 if self.datalen == 0 { return Vec::new(); }
154                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
155                 self.data = std::ptr::null_mut();
156                 self.datalen = 0;
157                 ret
158         }
159         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_usizeTransactionZ] {
160                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
161         }
162 }
163 impl From<Vec<crate::c_types::derived::C2Tuple_usizeTransactionZ>> for CVec_C2Tuple_usizeTransactionZZ {
164         fn from(v: Vec<crate::c_types::derived::C2Tuple_usizeTransactionZ>) -> Self {
165                 let datalen = v.len();
166                 let data = Box::into_raw(v.into_boxed_slice());
167                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
168         }
169 }
170 #[no_mangle]
171 pub extern "C" fn CVec_C2Tuple_usizeTransactionZZ_free(_res: CVec_C2Tuple_usizeTransactionZZ) { }
172 impl Drop for CVec_C2Tuple_usizeTransactionZZ {
173         fn drop(&mut self) {
174                 if self.datalen == 0 { return; }
175                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
176         }
177 }
178 #[repr(C)]
179 pub union CResult_NoneChannelMonitorUpdateErrZPtr {
180         /// Note that this value is always NULL, as there are no contents in the OK variant
181         pub result: *mut std::ffi::c_void,
182         pub err: *mut crate::chain::channelmonitor::ChannelMonitorUpdateErr,
183 }
184 #[repr(C)]
185 pub struct CResult_NoneChannelMonitorUpdateErrZ {
186         pub contents: CResult_NoneChannelMonitorUpdateErrZPtr,
187         pub result_ok: bool,
188 }
189 #[no_mangle]
190 pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_ok() -> CResult_NoneChannelMonitorUpdateErrZ {
191         CResult_NoneChannelMonitorUpdateErrZ {
192                 contents: CResult_NoneChannelMonitorUpdateErrZPtr {
193                         result: std::ptr::null_mut(),
194                 },
195                 result_ok: true,
196         }
197 }
198 #[no_mangle]
199 pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_err(e: crate::chain::channelmonitor::ChannelMonitorUpdateErr) -> CResult_NoneChannelMonitorUpdateErrZ {
200         CResult_NoneChannelMonitorUpdateErrZ {
201                 contents: CResult_NoneChannelMonitorUpdateErrZPtr {
202                         err: Box::into_raw(Box::new(e)),
203                 },
204                 result_ok: false,
205         }
206 }
207 #[no_mangle]
208 pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_free(_res: CResult_NoneChannelMonitorUpdateErrZ) { }
209 impl Drop for CResult_NoneChannelMonitorUpdateErrZ {
210         fn drop(&mut self) {
211                 if self.result_ok {
212                 } else {
213                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
214                                 let _ = unsafe { Box::from_raw(self.contents.err) };
215                         }
216                 }
217         }
218 }
219 impl From<crate::c_types::CResultTempl<u8, crate::chain::channelmonitor::ChannelMonitorUpdateErr>> for CResult_NoneChannelMonitorUpdateErrZ {
220         fn from(mut o: crate::c_types::CResultTempl<u8, crate::chain::channelmonitor::ChannelMonitorUpdateErr>) -> Self {
221                 let contents = if o.result_ok {
222                         let _ = unsafe { Box::from_raw(o.contents.result) };
223                         o.contents.result = std::ptr::null_mut();
224                         CResult_NoneChannelMonitorUpdateErrZPtr { result: std::ptr::null_mut() }
225                 } else {
226                         let err = unsafe { o.contents.err };
227                         unsafe { o.contents.err = std::ptr::null_mut(); }
228                         CResult_NoneChannelMonitorUpdateErrZPtr { err }
229                 };
230                 Self {
231                         contents,
232                         result_ok: o.result_ok,
233                 }
234         }
235 }
236 impl Clone for CResult_NoneChannelMonitorUpdateErrZ {
237         fn clone(&self) -> Self {
238                 if self.result_ok {
239                         Self { result_ok: true, contents: CResult_NoneChannelMonitorUpdateErrZPtr {
240                                 result: std::ptr::null_mut()
241                         } }
242                 } else {
243                         Self { result_ok: false, contents: CResult_NoneChannelMonitorUpdateErrZPtr {
244                                 err: Box::into_raw(Box::new(<crate::chain::channelmonitor::ChannelMonitorUpdateErr>::clone(unsafe { &*self.contents.err })))
245                         } }
246                 }
247         }
248 }
249 #[no_mangle]
250 pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_clone(orig: &CResult_NoneChannelMonitorUpdateErrZ) -> CResult_NoneChannelMonitorUpdateErrZ { orig.clone() }
251 #[repr(C)]
252 pub struct CVec_MonitorEventZ {
253         pub data: *mut crate::chain::channelmonitor::MonitorEvent,
254         pub datalen: usize
255 }
256 impl CVec_MonitorEventZ {
257         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::chain::channelmonitor::MonitorEvent> {
258                 if self.datalen == 0 { return Vec::new(); }
259                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
260                 self.data = std::ptr::null_mut();
261                 self.datalen = 0;
262                 ret
263         }
264         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::chain::channelmonitor::MonitorEvent] {
265                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
266         }
267 }
268 impl From<Vec<crate::chain::channelmonitor::MonitorEvent>> for CVec_MonitorEventZ {
269         fn from(v: Vec<crate::chain::channelmonitor::MonitorEvent>) -> Self {
270                 let datalen = v.len();
271                 let data = Box::into_raw(v.into_boxed_slice());
272                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
273         }
274 }
275 #[no_mangle]
276 pub extern "C" fn CVec_MonitorEventZ_free(_res: CVec_MonitorEventZ) { }
277 impl Drop for CVec_MonitorEventZ {
278         fn drop(&mut self) {
279                 if self.datalen == 0 { return; }
280                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
281         }
282 }
283 impl Clone for CVec_MonitorEventZ {
284         fn clone(&self) -> Self {
285                 let mut res = Vec::new();
286                 if self.datalen == 0 { return Self::from(res); }
287                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
288                 Self::from(res)
289         }
290 }
291 #[repr(C)]
292 pub union CResult_ChannelMonitorUpdateDecodeErrorZPtr {
293         pub result: *mut crate::chain::channelmonitor::ChannelMonitorUpdate,
294         pub err: *mut crate::ln::msgs::DecodeError,
295 }
296 #[repr(C)]
297 pub struct CResult_ChannelMonitorUpdateDecodeErrorZ {
298         pub contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr,
299         pub result_ok: bool,
300 }
301 #[no_mangle]
302 pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o: crate::chain::channelmonitor::ChannelMonitorUpdate) -> CResult_ChannelMonitorUpdateDecodeErrorZ {
303         CResult_ChannelMonitorUpdateDecodeErrorZ {
304                 contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr {
305                         result: Box::into_raw(Box::new(o)),
306                 },
307                 result_ok: true,
308         }
309 }
310 #[no_mangle]
311 pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ChannelMonitorUpdateDecodeErrorZ {
312         CResult_ChannelMonitorUpdateDecodeErrorZ {
313                 contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr {
314                         err: Box::into_raw(Box::new(e)),
315                 },
316                 result_ok: false,
317         }
318 }
319 #[no_mangle]
320 pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res: CResult_ChannelMonitorUpdateDecodeErrorZ) { }
321 impl Drop for CResult_ChannelMonitorUpdateDecodeErrorZ {
322         fn drop(&mut self) {
323                 if self.result_ok {
324                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
325                                 let _ = unsafe { Box::from_raw(self.contents.result) };
326                         }
327                 } else {
328                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
329                                 let _ = unsafe { Box::from_raw(self.contents.err) };
330                         }
331                 }
332         }
333 }
334 impl From<crate::c_types::CResultTempl<crate::chain::channelmonitor::ChannelMonitorUpdate, crate::ln::msgs::DecodeError>> for CResult_ChannelMonitorUpdateDecodeErrorZ {
335         fn from(mut o: crate::c_types::CResultTempl<crate::chain::channelmonitor::ChannelMonitorUpdate, crate::ln::msgs::DecodeError>) -> Self {
336                 let contents = if o.result_ok {
337                         let result = unsafe { o.contents.result };
338                         unsafe { o.contents.result = std::ptr::null_mut() };
339                         CResult_ChannelMonitorUpdateDecodeErrorZPtr { result }
340                 } else {
341                         let err = unsafe { o.contents.err };
342                         unsafe { o.contents.err = std::ptr::null_mut(); }
343                         CResult_ChannelMonitorUpdateDecodeErrorZPtr { err }
344                 };
345                 Self {
346                         contents,
347                         result_ok: o.result_ok,
348                 }
349         }
350 }
351 impl Clone for CResult_ChannelMonitorUpdateDecodeErrorZ {
352         fn clone(&self) -> Self {
353                 if self.result_ok {
354                         Self { result_ok: true, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr {
355                                 result: Box::into_raw(Box::new(<crate::chain::channelmonitor::ChannelMonitorUpdate>::clone(unsafe { &*self.contents.result })))
356                         } }
357                 } else {
358                         Self { result_ok: false, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr {
359                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
360                         } }
361                 }
362         }
363 }
364 #[no_mangle]
365 pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> CResult_ChannelMonitorUpdateDecodeErrorZ { orig.clone() }
366 #[repr(C)]
367 pub union CResult_NoneMonitorUpdateErrorZPtr {
368         /// Note that this value is always NULL, as there are no contents in the OK variant
369         pub result: *mut std::ffi::c_void,
370         pub err: *mut crate::chain::channelmonitor::MonitorUpdateError,
371 }
372 #[repr(C)]
373 pub struct CResult_NoneMonitorUpdateErrorZ {
374         pub contents: CResult_NoneMonitorUpdateErrorZPtr,
375         pub result_ok: bool,
376 }
377 #[no_mangle]
378 pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_ok() -> CResult_NoneMonitorUpdateErrorZ {
379         CResult_NoneMonitorUpdateErrorZ {
380                 contents: CResult_NoneMonitorUpdateErrorZPtr {
381                         result: std::ptr::null_mut(),
382                 },
383                 result_ok: true,
384         }
385 }
386 #[no_mangle]
387 pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_err(e: crate::chain::channelmonitor::MonitorUpdateError) -> CResult_NoneMonitorUpdateErrorZ {
388         CResult_NoneMonitorUpdateErrorZ {
389                 contents: CResult_NoneMonitorUpdateErrorZPtr {
390                         err: Box::into_raw(Box::new(e)),
391                 },
392                 result_ok: false,
393         }
394 }
395 #[no_mangle]
396 pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_free(_res: CResult_NoneMonitorUpdateErrorZ) { }
397 impl Drop for CResult_NoneMonitorUpdateErrorZ {
398         fn drop(&mut self) {
399                 if self.result_ok {
400                 } else {
401                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
402                                 let _ = unsafe { Box::from_raw(self.contents.err) };
403                         }
404                 }
405         }
406 }
407 impl From<crate::c_types::CResultTempl<u8, crate::chain::channelmonitor::MonitorUpdateError>> for CResult_NoneMonitorUpdateErrorZ {
408         fn from(mut o: crate::c_types::CResultTempl<u8, crate::chain::channelmonitor::MonitorUpdateError>) -> Self {
409                 let contents = if o.result_ok {
410                         let _ = unsafe { Box::from_raw(o.contents.result) };
411                         o.contents.result = std::ptr::null_mut();
412                         CResult_NoneMonitorUpdateErrorZPtr { result: std::ptr::null_mut() }
413                 } else {
414                         let err = unsafe { o.contents.err };
415                         unsafe { o.contents.err = std::ptr::null_mut(); }
416                         CResult_NoneMonitorUpdateErrorZPtr { err }
417                 };
418                 Self {
419                         contents,
420                         result_ok: o.result_ok,
421                 }
422         }
423 }
424 impl Clone for CResult_NoneMonitorUpdateErrorZ {
425         fn clone(&self) -> Self {
426                 if self.result_ok {
427                         Self { result_ok: true, contents: CResult_NoneMonitorUpdateErrorZPtr {
428                                 result: std::ptr::null_mut()
429                         } }
430                 } else {
431                         Self { result_ok: false, contents: CResult_NoneMonitorUpdateErrorZPtr {
432                                 err: Box::into_raw(Box::new(<crate::chain::channelmonitor::MonitorUpdateError>::clone(unsafe { &*self.contents.err })))
433                         } }
434                 }
435         }
436 }
437 #[no_mangle]
438 pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_clone(orig: &CResult_NoneMonitorUpdateErrorZ) -> CResult_NoneMonitorUpdateErrorZ { orig.clone() }
439 #[repr(C)]
440 pub struct C2Tuple_OutPointScriptZ {
441         pub a: crate::chain::transaction::OutPoint,
442         pub b: crate::c_types::derived::CVec_u8Z,
443 }
444 impl From<(crate::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)> for C2Tuple_OutPointScriptZ {
445         fn from (tup: (crate::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)) -> Self {
446                 Self {
447                         a: tup.0,
448                         b: tup.1,
449                 }
450         }
451 }
452 impl C2Tuple_OutPointScriptZ {
453         #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z) {
454                 (self.a, self.b)
455         }
456 }
457 #[no_mangle]
458 pub extern "C" fn C2Tuple_OutPointScriptZ_new(a: crate::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_OutPointScriptZ {
459         C2Tuple_OutPointScriptZ { a, b, }
460 }
461
462 #[no_mangle]
463 pub extern "C" fn C2Tuple_OutPointScriptZ_free(_res: C2Tuple_OutPointScriptZ) { }
464 #[repr(C)]
465 pub struct CVec_TransactionZ {
466         pub data: *mut crate::c_types::Transaction,
467         pub datalen: usize
468 }
469 impl CVec_TransactionZ {
470         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::Transaction> {
471                 if self.datalen == 0 { return Vec::new(); }
472                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
473                 self.data = std::ptr::null_mut();
474                 self.datalen = 0;
475                 ret
476         }
477         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Transaction] {
478                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
479         }
480 }
481 impl From<Vec<crate::c_types::Transaction>> for CVec_TransactionZ {
482         fn from(v: Vec<crate::c_types::Transaction>) -> Self {
483                 let datalen = v.len();
484                 let data = Box::into_raw(v.into_boxed_slice());
485                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
486         }
487 }
488 #[no_mangle]
489 pub extern "C" fn CVec_TransactionZ_free(_res: CVec_TransactionZ) { }
490 impl Drop for CVec_TransactionZ {
491         fn drop(&mut self) {
492                 if self.datalen == 0 { return; }
493                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
494         }
495 }
496 #[repr(C)]
497 pub struct C2Tuple_u32TxOutZ {
498         pub a: u32,
499         pub b: crate::c_types::TxOut,
500 }
501 impl From<(u32, crate::c_types::TxOut)> for C2Tuple_u32TxOutZ {
502         fn from (tup: (u32, crate::c_types::TxOut)) -> Self {
503                 Self {
504                         a: tup.0,
505                         b: tup.1,
506                 }
507         }
508 }
509 impl C2Tuple_u32TxOutZ {
510         #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::TxOut) {
511                 (self.a, self.b)
512         }
513 }
514 impl Clone for C2Tuple_u32TxOutZ {
515         fn clone(&self) -> Self {
516                 Self {
517                         a: self.a.clone(),
518                         b: self.b.clone(),
519                 }
520         }
521 }
522 #[no_mangle]
523 pub extern "C" fn C2Tuple_u32TxOutZ_clone(orig: &C2Tuple_u32TxOutZ) -> C2Tuple_u32TxOutZ { orig.clone() }
524 #[no_mangle]
525 pub extern "C" fn C2Tuple_u32TxOutZ_new(a: u32, b: crate::c_types::TxOut) -> C2Tuple_u32TxOutZ {
526         C2Tuple_u32TxOutZ { a, b, }
527 }
528
529 #[no_mangle]
530 pub extern "C" fn C2Tuple_u32TxOutZ_free(_res: C2Tuple_u32TxOutZ) { }
531 #[repr(C)]
532 pub struct CVec_C2Tuple_u32TxOutZZ {
533         pub data: *mut crate::c_types::derived::C2Tuple_u32TxOutZ,
534         pub datalen: usize
535 }
536 impl CVec_C2Tuple_u32TxOutZZ {
537         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::C2Tuple_u32TxOutZ> {
538                 if self.datalen == 0 { return Vec::new(); }
539                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
540                 self.data = std::ptr::null_mut();
541                 self.datalen = 0;
542                 ret
543         }
544         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32TxOutZ] {
545                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
546         }
547 }
548 impl From<Vec<crate::c_types::derived::C2Tuple_u32TxOutZ>> for CVec_C2Tuple_u32TxOutZZ {
549         fn from(v: Vec<crate::c_types::derived::C2Tuple_u32TxOutZ>) -> Self {
550                 let datalen = v.len();
551                 let data = Box::into_raw(v.into_boxed_slice());
552                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
553         }
554 }
555 #[no_mangle]
556 pub extern "C" fn CVec_C2Tuple_u32TxOutZZ_free(_res: CVec_C2Tuple_u32TxOutZZ) { }
557 impl Drop for CVec_C2Tuple_u32TxOutZZ {
558         fn drop(&mut self) {
559                 if self.datalen == 0 { return; }
560                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
561         }
562 }
563 impl Clone for CVec_C2Tuple_u32TxOutZZ {
564         fn clone(&self) -> Self {
565                 let mut res = Vec::new();
566                 if self.datalen == 0 { return Self::from(res); }
567                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
568                 Self::from(res)
569         }
570 }
571 #[repr(C)]
572 pub struct C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ {
573         pub a: crate::c_types::ThirtyTwoBytes,
574         pub b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ,
575 }
576 impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)> for C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ {
577         fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)) -> Self {
578                 Self {
579                         a: tup.0,
580                         b: tup.1,
581                 }
582         }
583 }
584 impl C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ {
585         #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) {
586                 (self.a, self.b)
587         }
588 }
589 #[no_mangle]
590 pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) -> C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ {
591         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { a, b, }
592 }
593
594 #[no_mangle]
595 pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res: C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) { }
596 #[repr(C)]
597 pub struct CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ {
598         pub data: *mut crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ,
599         pub datalen: usize
600 }
601 impl CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ {
602         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ> {
603                 if self.datalen == 0 { return Vec::new(); }
604                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
605                 self.data = std::ptr::null_mut();
606                 self.datalen = 0;
607                 ret
608         }
609         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ] {
610                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
611         }
612 }
613 impl From<Vec<crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ>> for CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ {
614         fn from(v: Vec<crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ>) -> Self {
615                 let datalen = v.len();
616                 let data = Box::into_raw(v.into_boxed_slice());
617                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
618         }
619 }
620 #[no_mangle]
621 pub extern "C" fn CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res: CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ) { }
622 impl Drop for CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ {
623         fn drop(&mut self) {
624                 if self.datalen == 0 { return; }
625                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
626         }
627 }
628 #[repr(C)]
629 pub struct C2Tuple_BlockHashChannelMonitorZ {
630         pub a: crate::c_types::ThirtyTwoBytes,
631         pub b: crate::chain::channelmonitor::ChannelMonitor,
632 }
633 impl From<(crate::c_types::ThirtyTwoBytes, crate::chain::channelmonitor::ChannelMonitor)> for C2Tuple_BlockHashChannelMonitorZ {
634         fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::chain::channelmonitor::ChannelMonitor)) -> Self {
635                 Self {
636                         a: tup.0,
637                         b: tup.1,
638                 }
639         }
640 }
641 impl C2Tuple_BlockHashChannelMonitorZ {
642         #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::chain::channelmonitor::ChannelMonitor) {
643                 (self.a, self.b)
644         }
645 }
646 #[no_mangle]
647 pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::chain::channelmonitor::ChannelMonitor) -> C2Tuple_BlockHashChannelMonitorZ {
648         C2Tuple_BlockHashChannelMonitorZ { a, b, }
649 }
650
651 #[no_mangle]
652 pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_free(_res: C2Tuple_BlockHashChannelMonitorZ) { }
653 #[repr(C)]
654 pub union CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr {
655         pub result: *mut crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ,
656         pub err: *mut crate::ln::msgs::DecodeError,
657 }
658 #[repr(C)]
659 pub struct CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ {
660         pub contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr,
661         pub result_ok: bool,
662 }
663 #[no_mangle]
664 pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ) -> CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ {
665         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ {
666                 contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr {
667                         result: Box::into_raw(Box::new(o)),
668                 },
669                 result_ok: true,
670         }
671 }
672 #[no_mangle]
673 pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ {
674         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ {
675                 contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr {
676                         err: Box::into_raw(Box::new(e)),
677                 },
678                 result_ok: false,
679         }
680 }
681 #[no_mangle]
682 pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ) { }
683 impl Drop for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ {
684         fn drop(&mut self) {
685                 if self.result_ok {
686                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
687                                 let _ = unsafe { Box::from_raw(self.contents.result) };
688                         }
689                 } else {
690                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
691                                 let _ = unsafe { Box::from_raw(self.contents.err) };
692                         }
693                 }
694         }
695 }
696 impl From<crate::c_types::CResultTempl<crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ, crate::ln::msgs::DecodeError>> for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ {
697         fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ, crate::ln::msgs::DecodeError>) -> Self {
698                 let contents = if o.result_ok {
699                         let result = unsafe { o.contents.result };
700                         unsafe { o.contents.result = std::ptr::null_mut() };
701                         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { result }
702                 } else {
703                         let err = unsafe { o.contents.err };
704                         unsafe { o.contents.err = std::ptr::null_mut(); }
705                         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { err }
706                 };
707                 Self {
708                         contents,
709                         result_ok: o.result_ok,
710                 }
711         }
712 }
713 #[repr(C)]
714 pub union CResult_SpendableOutputDescriptorDecodeErrorZPtr {
715         pub result: *mut crate::chain::keysinterface::SpendableOutputDescriptor,
716         pub err: *mut crate::ln::msgs::DecodeError,
717 }
718 #[repr(C)]
719 pub struct CResult_SpendableOutputDescriptorDecodeErrorZ {
720         pub contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr,
721         pub result_ok: bool,
722 }
723 #[no_mangle]
724 pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o: crate::chain::keysinterface::SpendableOutputDescriptor) -> CResult_SpendableOutputDescriptorDecodeErrorZ {
725         CResult_SpendableOutputDescriptorDecodeErrorZ {
726                 contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr {
727                         result: Box::into_raw(Box::new(o)),
728                 },
729                 result_ok: true,
730         }
731 }
732 #[no_mangle]
733 pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_SpendableOutputDescriptorDecodeErrorZ {
734         CResult_SpendableOutputDescriptorDecodeErrorZ {
735                 contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr {
736                         err: Box::into_raw(Box::new(e)),
737                 },
738                 result_ok: false,
739         }
740 }
741 #[no_mangle]
742 pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res: CResult_SpendableOutputDescriptorDecodeErrorZ) { }
743 impl Drop for CResult_SpendableOutputDescriptorDecodeErrorZ {
744         fn drop(&mut self) {
745                 if self.result_ok {
746                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
747                                 let _ = unsafe { Box::from_raw(self.contents.result) };
748                         }
749                 } else {
750                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
751                                 let _ = unsafe { Box::from_raw(self.contents.err) };
752                         }
753                 }
754         }
755 }
756 impl From<crate::c_types::CResultTempl<crate::chain::keysinterface::SpendableOutputDescriptor, crate::ln::msgs::DecodeError>> for CResult_SpendableOutputDescriptorDecodeErrorZ {
757         fn from(mut o: crate::c_types::CResultTempl<crate::chain::keysinterface::SpendableOutputDescriptor, crate::ln::msgs::DecodeError>) -> Self {
758                 let contents = if o.result_ok {
759                         let result = unsafe { o.contents.result };
760                         unsafe { o.contents.result = std::ptr::null_mut() };
761                         CResult_SpendableOutputDescriptorDecodeErrorZPtr { result }
762                 } else {
763                         let err = unsafe { o.contents.err };
764                         unsafe { o.contents.err = std::ptr::null_mut(); }
765                         CResult_SpendableOutputDescriptorDecodeErrorZPtr { err }
766                 };
767                 Self {
768                         contents,
769                         result_ok: o.result_ok,
770                 }
771         }
772 }
773 impl Clone for CResult_SpendableOutputDescriptorDecodeErrorZ {
774         fn clone(&self) -> Self {
775                 if self.result_ok {
776                         Self { result_ok: true, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr {
777                                 result: Box::into_raw(Box::new(<crate::chain::keysinterface::SpendableOutputDescriptor>::clone(unsafe { &*self.contents.result })))
778                         } }
779                 } else {
780                         Self { result_ok: false, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr {
781                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
782                         } }
783                 }
784         }
785 }
786 #[no_mangle]
787 pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> CResult_SpendableOutputDescriptorDecodeErrorZ { orig.clone() }
788 #[repr(C)]
789 pub struct CVec_SignatureZ {
790         pub data: *mut crate::c_types::Signature,
791         pub datalen: usize
792 }
793 impl CVec_SignatureZ {
794         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::Signature> {
795                 if self.datalen == 0 { return Vec::new(); }
796                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
797                 self.data = std::ptr::null_mut();
798                 self.datalen = 0;
799                 ret
800         }
801         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Signature] {
802                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
803         }
804 }
805 impl From<Vec<crate::c_types::Signature>> for CVec_SignatureZ {
806         fn from(v: Vec<crate::c_types::Signature>) -> Self {
807                 let datalen = v.len();
808                 let data = Box::into_raw(v.into_boxed_slice());
809                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
810         }
811 }
812 #[no_mangle]
813 pub extern "C" fn CVec_SignatureZ_free(_res: CVec_SignatureZ) { }
814 impl Drop for CVec_SignatureZ {
815         fn drop(&mut self) {
816                 if self.datalen == 0 { return; }
817                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
818         }
819 }
820 impl Clone for CVec_SignatureZ {
821         fn clone(&self) -> Self {
822                 let mut res = Vec::new();
823                 if self.datalen == 0 { return Self::from(res); }
824                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
825                 Self::from(res)
826         }
827 }
828 #[repr(C)]
829 pub struct C2Tuple_SignatureCVec_SignatureZZ {
830         pub a: crate::c_types::Signature,
831         pub b: crate::c_types::derived::CVec_SignatureZ,
832 }
833 impl From<(crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ)> for C2Tuple_SignatureCVec_SignatureZZ {
834         fn from (tup: (crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ)) -> Self {
835                 Self {
836                         a: tup.0,
837                         b: tup.1,
838                 }
839         }
840 }
841 impl C2Tuple_SignatureCVec_SignatureZZ {
842         #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ) {
843                 (self.a, self.b)
844         }
845 }
846 impl Clone for C2Tuple_SignatureCVec_SignatureZZ {
847         fn clone(&self) -> Self {
848                 Self {
849                         a: self.a.clone(),
850                         b: self.b.clone(),
851                 }
852         }
853 }
854 #[no_mangle]
855 pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_clone(orig: &C2Tuple_SignatureCVec_SignatureZZ) -> C2Tuple_SignatureCVec_SignatureZZ { orig.clone() }
856 #[no_mangle]
857 pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_new(a: crate::c_types::Signature, b: crate::c_types::derived::CVec_SignatureZ) -> C2Tuple_SignatureCVec_SignatureZZ {
858         C2Tuple_SignatureCVec_SignatureZZ { a, b, }
859 }
860
861 #[no_mangle]
862 pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_free(_res: C2Tuple_SignatureCVec_SignatureZZ) { }
863 #[repr(C)]
864 pub union CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr {
865         pub result: *mut crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ,
866         /// Note that this value is always NULL, as there are no contents in the Err variant
867         pub err: *mut std::ffi::c_void,
868 }
869 #[repr(C)]
870 pub struct CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
871         pub contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr,
872         pub result_ok: bool,
873 }
874 #[no_mangle]
875 pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o: crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
876         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
877                 contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr {
878                         result: Box::into_raw(Box::new(o)),
879                 },
880                 result_ok: true,
881         }
882 }
883 #[no_mangle]
884 pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
885         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
886                 contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr {
887                         err: std::ptr::null_mut(),
888                 },
889                 result_ok: false,
890         }
891 }
892 #[no_mangle]
893 pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) { }
894 impl Drop for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
895         fn drop(&mut self) {
896                 if self.result_ok {
897                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
898                                 let _ = unsafe { Box::from_raw(self.contents.result) };
899                         }
900                 } else {
901                 }
902         }
903 }
904 impl From<crate::c_types::CResultTempl<crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ, u8>> for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
905         fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ, u8>) -> Self {
906                 let contents = if o.result_ok {
907                         let result = unsafe { o.contents.result };
908                         unsafe { o.contents.result = std::ptr::null_mut() };
909                         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { result }
910                 } else {
911                         let _ = unsafe { Box::from_raw(o.contents.err) };
912                         o.contents.err = std::ptr::null_mut();
913                         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { err: std::ptr::null_mut() }
914                 };
915                 Self {
916                         contents,
917                         result_ok: o.result_ok,
918                 }
919         }
920 }
921 impl Clone for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
922         fn clone(&self) -> Self {
923                 if self.result_ok {
924                         Self { result_ok: true, contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr {
925                                 result: Box::into_raw(Box::new(<crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ>::clone(unsafe { &*self.contents.result })))
926                         } }
927                 } else {
928                         Self { result_ok: false, contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr {
929                                 err: std::ptr::null_mut()
930                         } }
931                 }
932         }
933 }
934 #[no_mangle]
935 pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig: &CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { orig.clone() }
936 #[repr(C)]
937 pub union CResult_SignatureNoneZPtr {
938         pub result: *mut crate::c_types::Signature,
939         /// Note that this value is always NULL, as there are no contents in the Err variant
940         pub err: *mut std::ffi::c_void,
941 }
942 #[repr(C)]
943 pub struct CResult_SignatureNoneZ {
944         pub contents: CResult_SignatureNoneZPtr,
945         pub result_ok: bool,
946 }
947 #[no_mangle]
948 pub extern "C" fn CResult_SignatureNoneZ_ok(o: crate::c_types::Signature) -> CResult_SignatureNoneZ {
949         CResult_SignatureNoneZ {
950                 contents: CResult_SignatureNoneZPtr {
951                         result: Box::into_raw(Box::new(o)),
952                 },
953                 result_ok: true,
954         }
955 }
956 #[no_mangle]
957 pub extern "C" fn CResult_SignatureNoneZ_err() -> CResult_SignatureNoneZ {
958         CResult_SignatureNoneZ {
959                 contents: CResult_SignatureNoneZPtr {
960                         err: std::ptr::null_mut(),
961                 },
962                 result_ok: false,
963         }
964 }
965 #[no_mangle]
966 pub extern "C" fn CResult_SignatureNoneZ_free(_res: CResult_SignatureNoneZ) { }
967 impl Drop for CResult_SignatureNoneZ {
968         fn drop(&mut self) {
969                 if self.result_ok {
970                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
971                                 let _ = unsafe { Box::from_raw(self.contents.result) };
972                         }
973                 } else {
974                 }
975         }
976 }
977 impl From<crate::c_types::CResultTempl<crate::c_types::Signature, u8>> for CResult_SignatureNoneZ {
978         fn from(mut o: crate::c_types::CResultTempl<crate::c_types::Signature, u8>) -> Self {
979                 let contents = if o.result_ok {
980                         let result = unsafe { o.contents.result };
981                         unsafe { o.contents.result = std::ptr::null_mut() };
982                         CResult_SignatureNoneZPtr { result }
983                 } else {
984                         let _ = unsafe { Box::from_raw(o.contents.err) };
985                         o.contents.err = std::ptr::null_mut();
986                         CResult_SignatureNoneZPtr { err: std::ptr::null_mut() }
987                 };
988                 Self {
989                         contents,
990                         result_ok: o.result_ok,
991                 }
992         }
993 }
994 impl Clone for CResult_SignatureNoneZ {
995         fn clone(&self) -> Self {
996                 if self.result_ok {
997                         Self { result_ok: true, contents: CResult_SignatureNoneZPtr {
998                                 result: Box::into_raw(Box::new(<crate::c_types::Signature>::clone(unsafe { &*self.contents.result })))
999                         } }
1000                 } else {
1001                         Self { result_ok: false, contents: CResult_SignatureNoneZPtr {
1002                                 err: std::ptr::null_mut()
1003                         } }
1004                 }
1005         }
1006 }
1007 #[no_mangle]
1008 pub extern "C" fn CResult_SignatureNoneZ_clone(orig: &CResult_SignatureNoneZ) -> CResult_SignatureNoneZ { orig.clone() }
1009 #[repr(C)]
1010 pub union CResult_ChanKeySignerDecodeErrorZPtr {
1011         pub result: *mut crate::chain::keysinterface::ChannelKeys,
1012         pub err: *mut crate::ln::msgs::DecodeError,
1013 }
1014 #[repr(C)]
1015 pub struct CResult_ChanKeySignerDecodeErrorZ {
1016         pub contents: CResult_ChanKeySignerDecodeErrorZPtr,
1017         pub result_ok: bool,
1018 }
1019 #[no_mangle]
1020 pub extern "C" fn CResult_ChanKeySignerDecodeErrorZ_ok(o: crate::chain::keysinterface::ChannelKeys) -> CResult_ChanKeySignerDecodeErrorZ {
1021         CResult_ChanKeySignerDecodeErrorZ {
1022                 contents: CResult_ChanKeySignerDecodeErrorZPtr {
1023                         result: Box::into_raw(Box::new(o)),
1024                 },
1025                 result_ok: true,
1026         }
1027 }
1028 #[no_mangle]
1029 pub extern "C" fn CResult_ChanKeySignerDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ChanKeySignerDecodeErrorZ {
1030         CResult_ChanKeySignerDecodeErrorZ {
1031                 contents: CResult_ChanKeySignerDecodeErrorZPtr {
1032                         err: Box::into_raw(Box::new(e)),
1033                 },
1034                 result_ok: false,
1035         }
1036 }
1037 #[no_mangle]
1038 pub extern "C" fn CResult_ChanKeySignerDecodeErrorZ_free(_res: CResult_ChanKeySignerDecodeErrorZ) { }
1039 impl Drop for CResult_ChanKeySignerDecodeErrorZ {
1040         fn drop(&mut self) {
1041                 if self.result_ok {
1042                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
1043                                 let _ = unsafe { Box::from_raw(self.contents.result) };
1044                         }
1045                 } else {
1046                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
1047                                 let _ = unsafe { Box::from_raw(self.contents.err) };
1048                         }
1049                 }
1050         }
1051 }
1052 impl From<crate::c_types::CResultTempl<crate::chain::keysinterface::ChannelKeys, crate::ln::msgs::DecodeError>> for CResult_ChanKeySignerDecodeErrorZ {
1053         fn from(mut o: crate::c_types::CResultTempl<crate::chain::keysinterface::ChannelKeys, crate::ln::msgs::DecodeError>) -> Self {
1054                 let contents = if o.result_ok {
1055                         let result = unsafe { o.contents.result };
1056                         unsafe { o.contents.result = std::ptr::null_mut() };
1057                         CResult_ChanKeySignerDecodeErrorZPtr { result }
1058                 } else {
1059                         let err = unsafe { o.contents.err };
1060                         unsafe { o.contents.err = std::ptr::null_mut(); }
1061                         CResult_ChanKeySignerDecodeErrorZPtr { err }
1062                 };
1063                 Self {
1064                         contents,
1065                         result_ok: o.result_ok,
1066                 }
1067         }
1068 }
1069 impl Clone for CResult_ChanKeySignerDecodeErrorZ {
1070         fn clone(&self) -> Self {
1071                 if self.result_ok {
1072                         Self { result_ok: true, contents: CResult_ChanKeySignerDecodeErrorZPtr {
1073                                 result: Box::into_raw(Box::new(<crate::chain::keysinterface::ChannelKeys>::clone(unsafe { &*self.contents.result })))
1074                         } }
1075                 } else {
1076                         Self { result_ok: false, contents: CResult_ChanKeySignerDecodeErrorZPtr {
1077                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
1078                         } }
1079                 }
1080         }
1081 }
1082 #[no_mangle]
1083 pub extern "C" fn CResult_ChanKeySignerDecodeErrorZ_clone(orig: &CResult_ChanKeySignerDecodeErrorZ) -> CResult_ChanKeySignerDecodeErrorZ { orig.clone() }
1084 #[repr(C)]
1085 pub union CResult_InMemoryChannelKeysDecodeErrorZPtr {
1086         pub result: *mut crate::chain::keysinterface::InMemoryChannelKeys,
1087         pub err: *mut crate::ln::msgs::DecodeError,
1088 }
1089 #[repr(C)]
1090 pub struct CResult_InMemoryChannelKeysDecodeErrorZ {
1091         pub contents: CResult_InMemoryChannelKeysDecodeErrorZPtr,
1092         pub result_ok: bool,
1093 }
1094 #[no_mangle]
1095 pub extern "C" fn CResult_InMemoryChannelKeysDecodeErrorZ_ok(o: crate::chain::keysinterface::InMemoryChannelKeys) -> CResult_InMemoryChannelKeysDecodeErrorZ {
1096         CResult_InMemoryChannelKeysDecodeErrorZ {
1097                 contents: CResult_InMemoryChannelKeysDecodeErrorZPtr {
1098                         result: Box::into_raw(Box::new(o)),
1099                 },
1100                 result_ok: true,
1101         }
1102 }
1103 #[no_mangle]
1104 pub extern "C" fn CResult_InMemoryChannelKeysDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_InMemoryChannelKeysDecodeErrorZ {
1105         CResult_InMemoryChannelKeysDecodeErrorZ {
1106                 contents: CResult_InMemoryChannelKeysDecodeErrorZPtr {
1107                         err: Box::into_raw(Box::new(e)),
1108                 },
1109                 result_ok: false,
1110         }
1111 }
1112 #[no_mangle]
1113 pub extern "C" fn CResult_InMemoryChannelKeysDecodeErrorZ_free(_res: CResult_InMemoryChannelKeysDecodeErrorZ) { }
1114 impl Drop for CResult_InMemoryChannelKeysDecodeErrorZ {
1115         fn drop(&mut self) {
1116                 if self.result_ok {
1117                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
1118                                 let _ = unsafe { Box::from_raw(self.contents.result) };
1119                         }
1120                 } else {
1121                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
1122                                 let _ = unsafe { Box::from_raw(self.contents.err) };
1123                         }
1124                 }
1125         }
1126 }
1127 impl From<crate::c_types::CResultTempl<crate::chain::keysinterface::InMemoryChannelKeys, crate::ln::msgs::DecodeError>> for CResult_InMemoryChannelKeysDecodeErrorZ {
1128         fn from(mut o: crate::c_types::CResultTempl<crate::chain::keysinterface::InMemoryChannelKeys, crate::ln::msgs::DecodeError>) -> Self {
1129                 let contents = if o.result_ok {
1130                         let result = unsafe { o.contents.result };
1131                         unsafe { o.contents.result = std::ptr::null_mut() };
1132                         CResult_InMemoryChannelKeysDecodeErrorZPtr { result }
1133                 } else {
1134                         let err = unsafe { o.contents.err };
1135                         unsafe { o.contents.err = std::ptr::null_mut(); }
1136                         CResult_InMemoryChannelKeysDecodeErrorZPtr { err }
1137                 };
1138                 Self {
1139                         contents,
1140                         result_ok: o.result_ok,
1141                 }
1142         }
1143 }
1144 impl Clone for CResult_InMemoryChannelKeysDecodeErrorZ {
1145         fn clone(&self) -> Self {
1146                 if self.result_ok {
1147                         Self { result_ok: true, contents: CResult_InMemoryChannelKeysDecodeErrorZPtr {
1148                                 result: Box::into_raw(Box::new(<crate::chain::keysinterface::InMemoryChannelKeys>::clone(unsafe { &*self.contents.result })))
1149                         } }
1150                 } else {
1151                         Self { result_ok: false, contents: CResult_InMemoryChannelKeysDecodeErrorZPtr {
1152                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
1153                         } }
1154                 }
1155         }
1156 }
1157 #[no_mangle]
1158 pub extern "C" fn CResult_InMemoryChannelKeysDecodeErrorZ_clone(orig: &CResult_InMemoryChannelKeysDecodeErrorZ) -> CResult_InMemoryChannelKeysDecodeErrorZ { orig.clone() }
1159 #[repr(C)]
1160 pub union CResult_TxOutAccessErrorZPtr {
1161         pub result: *mut crate::c_types::TxOut,
1162         pub err: *mut crate::chain::AccessError,
1163 }
1164 #[repr(C)]
1165 pub struct CResult_TxOutAccessErrorZ {
1166         pub contents: CResult_TxOutAccessErrorZPtr,
1167         pub result_ok: bool,
1168 }
1169 #[no_mangle]
1170 pub extern "C" fn CResult_TxOutAccessErrorZ_ok(o: crate::c_types::TxOut) -> CResult_TxOutAccessErrorZ {
1171         CResult_TxOutAccessErrorZ {
1172                 contents: CResult_TxOutAccessErrorZPtr {
1173                         result: Box::into_raw(Box::new(o)),
1174                 },
1175                 result_ok: true,
1176         }
1177 }
1178 #[no_mangle]
1179 pub extern "C" fn CResult_TxOutAccessErrorZ_err(e: crate::chain::AccessError) -> CResult_TxOutAccessErrorZ {
1180         CResult_TxOutAccessErrorZ {
1181                 contents: CResult_TxOutAccessErrorZPtr {
1182                         err: Box::into_raw(Box::new(e)),
1183                 },
1184                 result_ok: false,
1185         }
1186 }
1187 #[no_mangle]
1188 pub extern "C" fn CResult_TxOutAccessErrorZ_free(_res: CResult_TxOutAccessErrorZ) { }
1189 impl Drop for CResult_TxOutAccessErrorZ {
1190         fn drop(&mut self) {
1191                 if self.result_ok {
1192                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
1193                                 let _ = unsafe { Box::from_raw(self.contents.result) };
1194                         }
1195                 } else {
1196                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
1197                                 let _ = unsafe { Box::from_raw(self.contents.err) };
1198                         }
1199                 }
1200         }
1201 }
1202 impl From<crate::c_types::CResultTempl<crate::c_types::TxOut, crate::chain::AccessError>> for CResult_TxOutAccessErrorZ {
1203         fn from(mut o: crate::c_types::CResultTempl<crate::c_types::TxOut, crate::chain::AccessError>) -> Self {
1204                 let contents = if o.result_ok {
1205                         let result = unsafe { o.contents.result };
1206                         unsafe { o.contents.result = std::ptr::null_mut() };
1207                         CResult_TxOutAccessErrorZPtr { result }
1208                 } else {
1209                         let err = unsafe { o.contents.err };
1210                         unsafe { o.contents.err = std::ptr::null_mut(); }
1211                         CResult_TxOutAccessErrorZPtr { err }
1212                 };
1213                 Self {
1214                         contents,
1215                         result_ok: o.result_ok,
1216                 }
1217         }
1218 }
1219 impl Clone for CResult_TxOutAccessErrorZ {
1220         fn clone(&self) -> Self {
1221                 if self.result_ok {
1222                         Self { result_ok: true, contents: CResult_TxOutAccessErrorZPtr {
1223                                 result: Box::into_raw(Box::new(<crate::c_types::TxOut>::clone(unsafe { &*self.contents.result })))
1224                         } }
1225                 } else {
1226                         Self { result_ok: false, contents: CResult_TxOutAccessErrorZPtr {
1227                                 err: Box::into_raw(Box::new(<crate::chain::AccessError>::clone(unsafe { &*self.contents.err })))
1228                         } }
1229                 }
1230         }
1231 }
1232 #[no_mangle]
1233 pub extern "C" fn CResult_TxOutAccessErrorZ_clone(orig: &CResult_TxOutAccessErrorZ) -> CResult_TxOutAccessErrorZ { orig.clone() }
1234 #[repr(C)]
1235 pub union CResult_NoneAPIErrorZPtr {
1236         /// Note that this value is always NULL, as there are no contents in the OK variant
1237         pub result: *mut std::ffi::c_void,
1238         pub err: *mut crate::util::errors::APIError,
1239 }
1240 #[repr(C)]
1241 pub struct CResult_NoneAPIErrorZ {
1242         pub contents: CResult_NoneAPIErrorZPtr,
1243         pub result_ok: bool,
1244 }
1245 #[no_mangle]
1246 pub extern "C" fn CResult_NoneAPIErrorZ_ok() -> CResult_NoneAPIErrorZ {
1247         CResult_NoneAPIErrorZ {
1248                 contents: CResult_NoneAPIErrorZPtr {
1249                         result: std::ptr::null_mut(),
1250                 },
1251                 result_ok: true,
1252         }
1253 }
1254 #[no_mangle]
1255 pub extern "C" fn CResult_NoneAPIErrorZ_err(e: crate::util::errors::APIError) -> CResult_NoneAPIErrorZ {
1256         CResult_NoneAPIErrorZ {
1257                 contents: CResult_NoneAPIErrorZPtr {
1258                         err: Box::into_raw(Box::new(e)),
1259                 },
1260                 result_ok: false,
1261         }
1262 }
1263 #[no_mangle]
1264 pub extern "C" fn CResult_NoneAPIErrorZ_free(_res: CResult_NoneAPIErrorZ) { }
1265 impl Drop for CResult_NoneAPIErrorZ {
1266         fn drop(&mut self) {
1267                 if self.result_ok {
1268                 } else {
1269                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
1270                                 let _ = unsafe { Box::from_raw(self.contents.err) };
1271                         }
1272                 }
1273         }
1274 }
1275 impl From<crate::c_types::CResultTempl<u8, crate::util::errors::APIError>> for CResult_NoneAPIErrorZ {
1276         fn from(mut o: crate::c_types::CResultTempl<u8, crate::util::errors::APIError>) -> Self {
1277                 let contents = if o.result_ok {
1278                         let _ = unsafe { Box::from_raw(o.contents.result) };
1279                         o.contents.result = std::ptr::null_mut();
1280                         CResult_NoneAPIErrorZPtr { result: std::ptr::null_mut() }
1281                 } else {
1282                         let err = unsafe { o.contents.err };
1283                         unsafe { o.contents.err = std::ptr::null_mut(); }
1284                         CResult_NoneAPIErrorZPtr { err }
1285                 };
1286                 Self {
1287                         contents,
1288                         result_ok: o.result_ok,
1289                 }
1290         }
1291 }
1292 impl Clone for CResult_NoneAPIErrorZ {
1293         fn clone(&self) -> Self {
1294                 if self.result_ok {
1295                         Self { result_ok: true, contents: CResult_NoneAPIErrorZPtr {
1296                                 result: std::ptr::null_mut()
1297                         } }
1298                 } else {
1299                         Self { result_ok: false, contents: CResult_NoneAPIErrorZPtr {
1300                                 err: Box::into_raw(Box::new(<crate::util::errors::APIError>::clone(unsafe { &*self.contents.err })))
1301                         } }
1302                 }
1303         }
1304 }
1305 #[no_mangle]
1306 pub extern "C" fn CResult_NoneAPIErrorZ_clone(orig: &CResult_NoneAPIErrorZ) -> CResult_NoneAPIErrorZ { orig.clone() }
1307 #[repr(C)]
1308 pub struct CVec_ChannelDetailsZ {
1309         pub data: *mut crate::ln::channelmanager::ChannelDetails,
1310         pub datalen: usize
1311 }
1312 impl CVec_ChannelDetailsZ {
1313         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::ln::channelmanager::ChannelDetails> {
1314                 if self.datalen == 0 { return Vec::new(); }
1315                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
1316                 self.data = std::ptr::null_mut();
1317                 self.datalen = 0;
1318                 ret
1319         }
1320         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::ln::channelmanager::ChannelDetails] {
1321                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
1322         }
1323 }
1324 impl From<Vec<crate::ln::channelmanager::ChannelDetails>> for CVec_ChannelDetailsZ {
1325         fn from(v: Vec<crate::ln::channelmanager::ChannelDetails>) -> Self {
1326                 let datalen = v.len();
1327                 let data = Box::into_raw(v.into_boxed_slice());
1328                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
1329         }
1330 }
1331 #[no_mangle]
1332 pub extern "C" fn CVec_ChannelDetailsZ_free(_res: CVec_ChannelDetailsZ) { }
1333 impl Drop for CVec_ChannelDetailsZ {
1334         fn drop(&mut self) {
1335                 if self.datalen == 0 { return; }
1336                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
1337         }
1338 }
1339 impl Clone for CVec_ChannelDetailsZ {
1340         fn clone(&self) -> Self {
1341                 let mut res = Vec::new();
1342                 if self.datalen == 0 { return Self::from(res); }
1343                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
1344                 Self::from(res)
1345         }
1346 }
1347 #[repr(C)]
1348 pub union CResult_NonePaymentSendFailureZPtr {
1349         /// Note that this value is always NULL, as there are no contents in the OK variant
1350         pub result: *mut std::ffi::c_void,
1351         pub err: *mut crate::ln::channelmanager::PaymentSendFailure,
1352 }
1353 #[repr(C)]
1354 pub struct CResult_NonePaymentSendFailureZ {
1355         pub contents: CResult_NonePaymentSendFailureZPtr,
1356         pub result_ok: bool,
1357 }
1358 #[no_mangle]
1359 pub extern "C" fn CResult_NonePaymentSendFailureZ_ok() -> CResult_NonePaymentSendFailureZ {
1360         CResult_NonePaymentSendFailureZ {
1361                 contents: CResult_NonePaymentSendFailureZPtr {
1362                         result: std::ptr::null_mut(),
1363                 },
1364                 result_ok: true,
1365         }
1366 }
1367 #[no_mangle]
1368 pub extern "C" fn CResult_NonePaymentSendFailureZ_err(e: crate::ln::channelmanager::PaymentSendFailure) -> CResult_NonePaymentSendFailureZ {
1369         CResult_NonePaymentSendFailureZ {
1370                 contents: CResult_NonePaymentSendFailureZPtr {
1371                         err: Box::into_raw(Box::new(e)),
1372                 },
1373                 result_ok: false,
1374         }
1375 }
1376 #[no_mangle]
1377 pub extern "C" fn CResult_NonePaymentSendFailureZ_free(_res: CResult_NonePaymentSendFailureZ) { }
1378 impl Drop for CResult_NonePaymentSendFailureZ {
1379         fn drop(&mut self) {
1380                 if self.result_ok {
1381                 } else {
1382                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
1383                                 let _ = unsafe { Box::from_raw(self.contents.err) };
1384                         }
1385                 }
1386         }
1387 }
1388 impl From<crate::c_types::CResultTempl<u8, crate::ln::channelmanager::PaymentSendFailure>> for CResult_NonePaymentSendFailureZ {
1389         fn from(mut o: crate::c_types::CResultTempl<u8, crate::ln::channelmanager::PaymentSendFailure>) -> Self {
1390                 let contents = if o.result_ok {
1391                         let _ = unsafe { Box::from_raw(o.contents.result) };
1392                         o.contents.result = std::ptr::null_mut();
1393                         CResult_NonePaymentSendFailureZPtr { result: std::ptr::null_mut() }
1394                 } else {
1395                         let err = unsafe { o.contents.err };
1396                         unsafe { o.contents.err = std::ptr::null_mut(); }
1397                         CResult_NonePaymentSendFailureZPtr { err }
1398                 };
1399                 Self {
1400                         contents,
1401                         result_ok: o.result_ok,
1402                 }
1403         }
1404 }
1405 impl Clone for CResult_NonePaymentSendFailureZ {
1406         fn clone(&self) -> Self {
1407                 if self.result_ok {
1408                         Self { result_ok: true, contents: CResult_NonePaymentSendFailureZPtr {
1409                                 result: std::ptr::null_mut()
1410                         } }
1411                 } else {
1412                         Self { result_ok: false, contents: CResult_NonePaymentSendFailureZPtr {
1413                                 err: Box::into_raw(Box::new(<crate::ln::channelmanager::PaymentSendFailure>::clone(unsafe { &*self.contents.err })))
1414                         } }
1415                 }
1416         }
1417 }
1418 #[no_mangle]
1419 pub extern "C" fn CResult_NonePaymentSendFailureZ_clone(orig: &CResult_NonePaymentSendFailureZ) -> CResult_NonePaymentSendFailureZ { orig.clone() }
1420 #[repr(C)]
1421 pub struct CVec_NetAddressZ {
1422         pub data: *mut crate::ln::msgs::NetAddress,
1423         pub datalen: usize
1424 }
1425 impl CVec_NetAddressZ {
1426         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::ln::msgs::NetAddress> {
1427                 if self.datalen == 0 { return Vec::new(); }
1428                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
1429                 self.data = std::ptr::null_mut();
1430                 self.datalen = 0;
1431                 ret
1432         }
1433         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::ln::msgs::NetAddress] {
1434                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
1435         }
1436 }
1437 impl From<Vec<crate::ln::msgs::NetAddress>> for CVec_NetAddressZ {
1438         fn from(v: Vec<crate::ln::msgs::NetAddress>) -> Self {
1439                 let datalen = v.len();
1440                 let data = Box::into_raw(v.into_boxed_slice());
1441                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
1442         }
1443 }
1444 #[no_mangle]
1445 pub extern "C" fn CVec_NetAddressZ_free(_res: CVec_NetAddressZ) { }
1446 impl Drop for CVec_NetAddressZ {
1447         fn drop(&mut self) {
1448                 if self.datalen == 0 { return; }
1449                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
1450         }
1451 }
1452 impl Clone for CVec_NetAddressZ {
1453         fn clone(&self) -> Self {
1454                 let mut res = Vec::new();
1455                 if self.datalen == 0 { return Self::from(res); }
1456                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
1457                 Self::from(res)
1458         }
1459 }
1460 #[repr(C)]
1461 pub struct CVec_ChannelMonitorZ {
1462         pub data: *mut crate::chain::channelmonitor::ChannelMonitor,
1463         pub datalen: usize
1464 }
1465 impl CVec_ChannelMonitorZ {
1466         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::chain::channelmonitor::ChannelMonitor> {
1467                 if self.datalen == 0 { return Vec::new(); }
1468                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
1469                 self.data = std::ptr::null_mut();
1470                 self.datalen = 0;
1471                 ret
1472         }
1473         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::chain::channelmonitor::ChannelMonitor] {
1474                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
1475         }
1476 }
1477 impl From<Vec<crate::chain::channelmonitor::ChannelMonitor>> for CVec_ChannelMonitorZ {
1478         fn from(v: Vec<crate::chain::channelmonitor::ChannelMonitor>) -> Self {
1479                 let datalen = v.len();
1480                 let data = Box::into_raw(v.into_boxed_slice());
1481                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
1482         }
1483 }
1484 #[no_mangle]
1485 pub extern "C" fn CVec_ChannelMonitorZ_free(_res: CVec_ChannelMonitorZ) { }
1486 impl Drop for CVec_ChannelMonitorZ {
1487         fn drop(&mut self) {
1488                 if self.datalen == 0 { return; }
1489                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
1490         }
1491 }
1492 #[repr(C)]
1493 pub struct C2Tuple_BlockHashChannelManagerZ {
1494         pub a: crate::c_types::ThirtyTwoBytes,
1495         pub b: crate::ln::channelmanager::ChannelManager,
1496 }
1497 impl From<(crate::c_types::ThirtyTwoBytes, crate::ln::channelmanager::ChannelManager)> for C2Tuple_BlockHashChannelManagerZ {
1498         fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::ln::channelmanager::ChannelManager)) -> Self {
1499                 Self {
1500                         a: tup.0,
1501                         b: tup.1,
1502                 }
1503         }
1504 }
1505 impl C2Tuple_BlockHashChannelManagerZ {
1506         #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::ln::channelmanager::ChannelManager) {
1507                 (self.a, self.b)
1508         }
1509 }
1510 #[no_mangle]
1511 pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::ln::channelmanager::ChannelManager) -> C2Tuple_BlockHashChannelManagerZ {
1512         C2Tuple_BlockHashChannelManagerZ { a, b, }
1513 }
1514
1515 #[no_mangle]
1516 pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_free(_res: C2Tuple_BlockHashChannelManagerZ) { }
1517 #[repr(C)]
1518 pub union CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr {
1519         pub result: *mut crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ,
1520         pub err: *mut crate::ln::msgs::DecodeError,
1521 }
1522 #[repr(C)]
1523 pub struct CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
1524         pub contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr,
1525         pub result_ok: bool,
1526 }
1527 #[no_mangle]
1528 pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ) -> CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
1529         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
1530                 contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr {
1531                         result: Box::into_raw(Box::new(o)),
1532                 },
1533                 result_ok: true,
1534         }
1535 }
1536 #[no_mangle]
1537 pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
1538         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
1539                 contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr {
1540                         err: Box::into_raw(Box::new(e)),
1541                 },
1542                 result_ok: false,
1543         }
1544 }
1545 #[no_mangle]
1546 pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ) { }
1547 impl Drop for CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
1548         fn drop(&mut self) {
1549                 if self.result_ok {
1550                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
1551                                 let _ = unsafe { Box::from_raw(self.contents.result) };
1552                         }
1553                 } else {
1554                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
1555                                 let _ = unsafe { Box::from_raw(self.contents.err) };
1556                         }
1557                 }
1558         }
1559 }
1560 impl From<crate::c_types::CResultTempl<crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ, crate::ln::msgs::DecodeError>> for CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
1561         fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ, crate::ln::msgs::DecodeError>) -> Self {
1562                 let contents = if o.result_ok {
1563                         let result = unsafe { o.contents.result };
1564                         unsafe { o.contents.result = std::ptr::null_mut() };
1565                         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { result }
1566                 } else {
1567                         let err = unsafe { o.contents.err };
1568                         unsafe { o.contents.err = std::ptr::null_mut(); }
1569                         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { err }
1570                 };
1571                 Self {
1572                         contents,
1573                         result_ok: o.result_ok,
1574                 }
1575         }
1576 }
1577 #[repr(C)]
1578 pub union CResult_NetAddressu8ZPtr {
1579         pub result: *mut crate::ln::msgs::NetAddress,
1580         pub err: *mut u8,
1581 }
1582 #[repr(C)]
1583 pub struct CResult_NetAddressu8Z {
1584         pub contents: CResult_NetAddressu8ZPtr,
1585         pub result_ok: bool,
1586 }
1587 #[no_mangle]
1588 pub extern "C" fn CResult_NetAddressu8Z_ok(o: crate::ln::msgs::NetAddress) -> CResult_NetAddressu8Z {
1589         CResult_NetAddressu8Z {
1590                 contents: CResult_NetAddressu8ZPtr {
1591                         result: Box::into_raw(Box::new(o)),
1592                 },
1593                 result_ok: true,
1594         }
1595 }
1596 #[no_mangle]
1597 pub extern "C" fn CResult_NetAddressu8Z_err(e: u8) -> CResult_NetAddressu8Z {
1598         CResult_NetAddressu8Z {
1599                 contents: CResult_NetAddressu8ZPtr {
1600                         err: Box::into_raw(Box::new(e)),
1601                 },
1602                 result_ok: false,
1603         }
1604 }
1605 #[no_mangle]
1606 pub extern "C" fn CResult_NetAddressu8Z_free(_res: CResult_NetAddressu8Z) { }
1607 impl Drop for CResult_NetAddressu8Z {
1608         fn drop(&mut self) {
1609                 if self.result_ok {
1610                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
1611                                 let _ = unsafe { Box::from_raw(self.contents.result) };
1612                         }
1613                 } else {
1614                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
1615                                 let _ = unsafe { Box::from_raw(self.contents.err) };
1616                         }
1617                 }
1618         }
1619 }
1620 impl From<crate::c_types::CResultTempl<crate::ln::msgs::NetAddress, u8>> for CResult_NetAddressu8Z {
1621         fn from(mut o: crate::c_types::CResultTempl<crate::ln::msgs::NetAddress, u8>) -> Self {
1622                 let contents = if o.result_ok {
1623                         let result = unsafe { o.contents.result };
1624                         unsafe { o.contents.result = std::ptr::null_mut() };
1625                         CResult_NetAddressu8ZPtr { result }
1626                 } else {
1627                         let err = unsafe { o.contents.err };
1628                         unsafe { o.contents.err = std::ptr::null_mut(); }
1629                         CResult_NetAddressu8ZPtr { err }
1630                 };
1631                 Self {
1632                         contents,
1633                         result_ok: o.result_ok,
1634                 }
1635         }
1636 }
1637 impl Clone for CResult_NetAddressu8Z {
1638         fn clone(&self) -> Self {
1639                 if self.result_ok {
1640                         Self { result_ok: true, contents: CResult_NetAddressu8ZPtr {
1641                                 result: Box::into_raw(Box::new(<crate::ln::msgs::NetAddress>::clone(unsafe { &*self.contents.result })))
1642                         } }
1643                 } else {
1644                         Self { result_ok: false, contents: CResult_NetAddressu8ZPtr {
1645                                 err: Box::into_raw(Box::new(<u8>::clone(unsafe { &*self.contents.err })))
1646                         } }
1647                 }
1648         }
1649 }
1650 #[no_mangle]
1651 pub extern "C" fn CResult_NetAddressu8Z_clone(orig: &CResult_NetAddressu8Z) -> CResult_NetAddressu8Z { orig.clone() }
1652 #[repr(C)]
1653 pub union CResult_CResult_NetAddressu8ZDecodeErrorZPtr {
1654         pub result: *mut crate::c_types::derived::CResult_NetAddressu8Z,
1655         pub err: *mut crate::ln::msgs::DecodeError,
1656 }
1657 #[repr(C)]
1658 pub struct CResult_CResult_NetAddressu8ZDecodeErrorZ {
1659         pub contents: CResult_CResult_NetAddressu8ZDecodeErrorZPtr,
1660         pub result_ok: bool,
1661 }
1662 #[no_mangle]
1663 pub extern "C" fn CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o: crate::c_types::derived::CResult_NetAddressu8Z) -> CResult_CResult_NetAddressu8ZDecodeErrorZ {
1664         CResult_CResult_NetAddressu8ZDecodeErrorZ {
1665                 contents: CResult_CResult_NetAddressu8ZDecodeErrorZPtr {
1666                         result: Box::into_raw(Box::new(o)),
1667                 },
1668                 result_ok: true,
1669         }
1670 }
1671 #[no_mangle]
1672 pub extern "C" fn CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_CResult_NetAddressu8ZDecodeErrorZ {
1673         CResult_CResult_NetAddressu8ZDecodeErrorZ {
1674                 contents: CResult_CResult_NetAddressu8ZDecodeErrorZPtr {
1675                         err: Box::into_raw(Box::new(e)),
1676                 },
1677                 result_ok: false,
1678         }
1679 }
1680 #[no_mangle]
1681 pub extern "C" fn CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res: CResult_CResult_NetAddressu8ZDecodeErrorZ) { }
1682 impl Drop for CResult_CResult_NetAddressu8ZDecodeErrorZ {
1683         fn drop(&mut self) {
1684                 if self.result_ok {
1685                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
1686                                 let _ = unsafe { Box::from_raw(self.contents.result) };
1687                         }
1688                 } else {
1689                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
1690                                 let _ = unsafe { Box::from_raw(self.contents.err) };
1691                         }
1692                 }
1693         }
1694 }
1695 impl From<crate::c_types::CResultTempl<crate::c_types::derived::CResult_NetAddressu8Z, crate::ln::msgs::DecodeError>> for CResult_CResult_NetAddressu8ZDecodeErrorZ {
1696         fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::CResult_NetAddressu8Z, crate::ln::msgs::DecodeError>) -> Self {
1697                 let contents = if o.result_ok {
1698                         let result = unsafe { o.contents.result };
1699                         unsafe { o.contents.result = std::ptr::null_mut() };
1700                         CResult_CResult_NetAddressu8ZDecodeErrorZPtr { result }
1701                 } else {
1702                         let err = unsafe { o.contents.err };
1703                         unsafe { o.contents.err = std::ptr::null_mut(); }
1704                         CResult_CResult_NetAddressu8ZDecodeErrorZPtr { err }
1705                 };
1706                 Self {
1707                         contents,
1708                         result_ok: o.result_ok,
1709                 }
1710         }
1711 }
1712 impl Clone for CResult_CResult_NetAddressu8ZDecodeErrorZ {
1713         fn clone(&self) -> Self {
1714                 if self.result_ok {
1715                         Self { result_ok: true, contents: CResult_CResult_NetAddressu8ZDecodeErrorZPtr {
1716                                 result: Box::into_raw(Box::new(<crate::c_types::derived::CResult_NetAddressu8Z>::clone(unsafe { &*self.contents.result })))
1717                         } }
1718                 } else {
1719                         Self { result_ok: false, contents: CResult_CResult_NetAddressu8ZDecodeErrorZPtr {
1720                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
1721                         } }
1722                 }
1723         }
1724 }
1725 #[no_mangle]
1726 pub extern "C" fn CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig: &CResult_CResult_NetAddressu8ZDecodeErrorZ) -> CResult_CResult_NetAddressu8ZDecodeErrorZ { orig.clone() }
1727 #[repr(C)]
1728 pub struct CVec_u64Z {
1729         pub data: *mut u64,
1730         pub datalen: usize
1731 }
1732 impl CVec_u64Z {
1733         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<u64> {
1734                 if self.datalen == 0 { return Vec::new(); }
1735                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
1736                 self.data = std::ptr::null_mut();
1737                 self.datalen = 0;
1738                 ret
1739         }
1740         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u64] {
1741                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
1742         }
1743 }
1744 impl From<Vec<u64>> for CVec_u64Z {
1745         fn from(v: Vec<u64>) -> Self {
1746                 let datalen = v.len();
1747                 let data = Box::into_raw(v.into_boxed_slice());
1748                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
1749         }
1750 }
1751 #[no_mangle]
1752 pub extern "C" fn CVec_u64Z_free(_res: CVec_u64Z) { }
1753 impl Drop for CVec_u64Z {
1754         fn drop(&mut self) {
1755                 if self.datalen == 0 { return; }
1756                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
1757         }
1758 }
1759 impl Clone for CVec_u64Z {
1760         fn clone(&self) -> Self {
1761                 let mut res = Vec::new();
1762                 if self.datalen == 0 { return Self::from(res); }
1763                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
1764                 Self::from(res)
1765         }
1766 }
1767 #[repr(C)]
1768 pub struct CVec_UpdateAddHTLCZ {
1769         pub data: *mut crate::ln::msgs::UpdateAddHTLC,
1770         pub datalen: usize
1771 }
1772 impl CVec_UpdateAddHTLCZ {
1773         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::ln::msgs::UpdateAddHTLC> {
1774                 if self.datalen == 0 { return Vec::new(); }
1775                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
1776                 self.data = std::ptr::null_mut();
1777                 self.datalen = 0;
1778                 ret
1779         }
1780         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::ln::msgs::UpdateAddHTLC] {
1781                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
1782         }
1783 }
1784 impl From<Vec<crate::ln::msgs::UpdateAddHTLC>> for CVec_UpdateAddHTLCZ {
1785         fn from(v: Vec<crate::ln::msgs::UpdateAddHTLC>) -> Self {
1786                 let datalen = v.len();
1787                 let data = Box::into_raw(v.into_boxed_slice());
1788                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
1789         }
1790 }
1791 #[no_mangle]
1792 pub extern "C" fn CVec_UpdateAddHTLCZ_free(_res: CVec_UpdateAddHTLCZ) { }
1793 impl Drop for CVec_UpdateAddHTLCZ {
1794         fn drop(&mut self) {
1795                 if self.datalen == 0 { return; }
1796                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
1797         }
1798 }
1799 impl Clone for CVec_UpdateAddHTLCZ {
1800         fn clone(&self) -> Self {
1801                 let mut res = Vec::new();
1802                 if self.datalen == 0 { return Self::from(res); }
1803                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
1804                 Self::from(res)
1805         }
1806 }
1807 #[repr(C)]
1808 pub struct CVec_UpdateFulfillHTLCZ {
1809         pub data: *mut crate::ln::msgs::UpdateFulfillHTLC,
1810         pub datalen: usize
1811 }
1812 impl CVec_UpdateFulfillHTLCZ {
1813         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::ln::msgs::UpdateFulfillHTLC> {
1814                 if self.datalen == 0 { return Vec::new(); }
1815                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
1816                 self.data = std::ptr::null_mut();
1817                 self.datalen = 0;
1818                 ret
1819         }
1820         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::ln::msgs::UpdateFulfillHTLC] {
1821                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
1822         }
1823 }
1824 impl From<Vec<crate::ln::msgs::UpdateFulfillHTLC>> for CVec_UpdateFulfillHTLCZ {
1825         fn from(v: Vec<crate::ln::msgs::UpdateFulfillHTLC>) -> Self {
1826                 let datalen = v.len();
1827                 let data = Box::into_raw(v.into_boxed_slice());
1828                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
1829         }
1830 }
1831 #[no_mangle]
1832 pub extern "C" fn CVec_UpdateFulfillHTLCZ_free(_res: CVec_UpdateFulfillHTLCZ) { }
1833 impl Drop for CVec_UpdateFulfillHTLCZ {
1834         fn drop(&mut self) {
1835                 if self.datalen == 0 { return; }
1836                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
1837         }
1838 }
1839 impl Clone for CVec_UpdateFulfillHTLCZ {
1840         fn clone(&self) -> Self {
1841                 let mut res = Vec::new();
1842                 if self.datalen == 0 { return Self::from(res); }
1843                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
1844                 Self::from(res)
1845         }
1846 }
1847 #[repr(C)]
1848 pub struct CVec_UpdateFailHTLCZ {
1849         pub data: *mut crate::ln::msgs::UpdateFailHTLC,
1850         pub datalen: usize
1851 }
1852 impl CVec_UpdateFailHTLCZ {
1853         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::ln::msgs::UpdateFailHTLC> {
1854                 if self.datalen == 0 { return Vec::new(); }
1855                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
1856                 self.data = std::ptr::null_mut();
1857                 self.datalen = 0;
1858                 ret
1859         }
1860         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::ln::msgs::UpdateFailHTLC] {
1861                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
1862         }
1863 }
1864 impl From<Vec<crate::ln::msgs::UpdateFailHTLC>> for CVec_UpdateFailHTLCZ {
1865         fn from(v: Vec<crate::ln::msgs::UpdateFailHTLC>) -> Self {
1866                 let datalen = v.len();
1867                 let data = Box::into_raw(v.into_boxed_slice());
1868                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
1869         }
1870 }
1871 #[no_mangle]
1872 pub extern "C" fn CVec_UpdateFailHTLCZ_free(_res: CVec_UpdateFailHTLCZ) { }
1873 impl Drop for CVec_UpdateFailHTLCZ {
1874         fn drop(&mut self) {
1875                 if self.datalen == 0 { return; }
1876                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
1877         }
1878 }
1879 impl Clone for CVec_UpdateFailHTLCZ {
1880         fn clone(&self) -> Self {
1881                 let mut res = Vec::new();
1882                 if self.datalen == 0 { return Self::from(res); }
1883                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
1884                 Self::from(res)
1885         }
1886 }
1887 #[repr(C)]
1888 pub struct CVec_UpdateFailMalformedHTLCZ {
1889         pub data: *mut crate::ln::msgs::UpdateFailMalformedHTLC,
1890         pub datalen: usize
1891 }
1892 impl CVec_UpdateFailMalformedHTLCZ {
1893         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::ln::msgs::UpdateFailMalformedHTLC> {
1894                 if self.datalen == 0 { return Vec::new(); }
1895                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
1896                 self.data = std::ptr::null_mut();
1897                 self.datalen = 0;
1898                 ret
1899         }
1900         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::ln::msgs::UpdateFailMalformedHTLC] {
1901                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
1902         }
1903 }
1904 impl From<Vec<crate::ln::msgs::UpdateFailMalformedHTLC>> for CVec_UpdateFailMalformedHTLCZ {
1905         fn from(v: Vec<crate::ln::msgs::UpdateFailMalformedHTLC>) -> Self {
1906                 let datalen = v.len();
1907                 let data = Box::into_raw(v.into_boxed_slice());
1908                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
1909         }
1910 }
1911 #[no_mangle]
1912 pub extern "C" fn CVec_UpdateFailMalformedHTLCZ_free(_res: CVec_UpdateFailMalformedHTLCZ) { }
1913 impl Drop for CVec_UpdateFailMalformedHTLCZ {
1914         fn drop(&mut self) {
1915                 if self.datalen == 0 { return; }
1916                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
1917         }
1918 }
1919 impl Clone for CVec_UpdateFailMalformedHTLCZ {
1920         fn clone(&self) -> Self {
1921                 let mut res = Vec::new();
1922                 if self.datalen == 0 { return Self::from(res); }
1923                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
1924                 Self::from(res)
1925         }
1926 }
1927 #[repr(C)]
1928 pub union CResult_boolLightningErrorZPtr {
1929         pub result: *mut bool,
1930         pub err: *mut crate::ln::msgs::LightningError,
1931 }
1932 #[repr(C)]
1933 pub struct CResult_boolLightningErrorZ {
1934         pub contents: CResult_boolLightningErrorZPtr,
1935         pub result_ok: bool,
1936 }
1937 #[no_mangle]
1938 pub extern "C" fn CResult_boolLightningErrorZ_ok(o: bool) -> CResult_boolLightningErrorZ {
1939         CResult_boolLightningErrorZ {
1940                 contents: CResult_boolLightningErrorZPtr {
1941                         result: Box::into_raw(Box::new(o)),
1942                 },
1943                 result_ok: true,
1944         }
1945 }
1946 #[no_mangle]
1947 pub extern "C" fn CResult_boolLightningErrorZ_err(e: crate::ln::msgs::LightningError) -> CResult_boolLightningErrorZ {
1948         CResult_boolLightningErrorZ {
1949                 contents: CResult_boolLightningErrorZPtr {
1950                         err: Box::into_raw(Box::new(e)),
1951                 },
1952                 result_ok: false,
1953         }
1954 }
1955 #[no_mangle]
1956 pub extern "C" fn CResult_boolLightningErrorZ_free(_res: CResult_boolLightningErrorZ) { }
1957 impl Drop for CResult_boolLightningErrorZ {
1958         fn drop(&mut self) {
1959                 if self.result_ok {
1960                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
1961                                 let _ = unsafe { Box::from_raw(self.contents.result) };
1962                         }
1963                 } else {
1964                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
1965                                 let _ = unsafe { Box::from_raw(self.contents.err) };
1966                         }
1967                 }
1968         }
1969 }
1970 impl From<crate::c_types::CResultTempl<bool, crate::ln::msgs::LightningError>> for CResult_boolLightningErrorZ {
1971         fn from(mut o: crate::c_types::CResultTempl<bool, crate::ln::msgs::LightningError>) -> Self {
1972                 let contents = if o.result_ok {
1973                         let result = unsafe { o.contents.result };
1974                         unsafe { o.contents.result = std::ptr::null_mut() };
1975                         CResult_boolLightningErrorZPtr { result }
1976                 } else {
1977                         let err = unsafe { o.contents.err };
1978                         unsafe { o.contents.err = std::ptr::null_mut(); }
1979                         CResult_boolLightningErrorZPtr { err }
1980                 };
1981                 Self {
1982                         contents,
1983                         result_ok: o.result_ok,
1984                 }
1985         }
1986 }
1987 impl Clone for CResult_boolLightningErrorZ {
1988         fn clone(&self) -> Self {
1989                 if self.result_ok {
1990                         Self { result_ok: true, contents: CResult_boolLightningErrorZPtr {
1991                                 result: Box::into_raw(Box::new(<bool>::clone(unsafe { &*self.contents.result })))
1992                         } }
1993                 } else {
1994                         Self { result_ok: false, contents: CResult_boolLightningErrorZPtr {
1995                                 err: Box::into_raw(Box::new(<crate::ln::msgs::LightningError>::clone(unsafe { &*self.contents.err })))
1996                         } }
1997                 }
1998         }
1999 }
2000 #[no_mangle]
2001 pub extern "C" fn CResult_boolLightningErrorZ_clone(orig: &CResult_boolLightningErrorZ) -> CResult_boolLightningErrorZ { orig.clone() }
2002 #[repr(C)]
2003 pub struct C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ {
2004         pub a: crate::ln::msgs::ChannelAnnouncement,
2005         pub b: crate::ln::msgs::ChannelUpdate,
2006         pub c: crate::ln::msgs::ChannelUpdate,
2007 }
2008 impl From<(crate::ln::msgs::ChannelAnnouncement, crate::ln::msgs::ChannelUpdate, crate::ln::msgs::ChannelUpdate)> for C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ {
2009         fn from (tup: (crate::ln::msgs::ChannelAnnouncement, crate::ln::msgs::ChannelUpdate, crate::ln::msgs::ChannelUpdate)) -> Self {
2010                 Self {
2011                         a: tup.0,
2012                         b: tup.1,
2013                         c: tup.2,
2014                 }
2015         }
2016 }
2017 impl C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ {
2018         #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::ln::msgs::ChannelAnnouncement, crate::ln::msgs::ChannelUpdate, crate::ln::msgs::ChannelUpdate) {
2019                 (self.a, self.b, self.c)
2020         }
2021 }
2022 impl Clone for C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ {
2023         fn clone(&self) -> Self {
2024                 Self {
2025                         a: self.a.clone(),
2026                         b: self.b.clone(),
2027                         c: self.c.clone(),
2028                 }
2029         }
2030 }
2031 #[no_mangle]
2032 pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig: &C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) -> C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { orig.clone() }
2033 #[no_mangle]
2034 pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a: crate::ln::msgs::ChannelAnnouncement, b: crate::ln::msgs::ChannelUpdate, c: crate::ln::msgs::ChannelUpdate) -> C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ {
2035         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { a, b, c, }
2036 }
2037
2038 #[no_mangle]
2039 pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res: C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) { }
2040 #[repr(C)]
2041 pub struct CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
2042         pub data: *mut crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ,
2043         pub datalen: usize
2044 }
2045 impl CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
2046         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ> {
2047                 if self.datalen == 0 { return Vec::new(); }
2048                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
2049                 self.data = std::ptr::null_mut();
2050                 self.datalen = 0;
2051                 ret
2052         }
2053         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ] {
2054                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
2055         }
2056 }
2057 impl From<Vec<crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ>> for CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
2058         fn from(v: Vec<crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ>) -> Self {
2059                 let datalen = v.len();
2060                 let data = Box::into_raw(v.into_boxed_slice());
2061                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
2062         }
2063 }
2064 #[no_mangle]
2065 pub extern "C" fn CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res: CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ) { }
2066 impl Drop for CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
2067         fn drop(&mut self) {
2068                 if self.datalen == 0 { return; }
2069                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
2070         }
2071 }
2072 impl Clone for CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
2073         fn clone(&self) -> Self {
2074                 let mut res = Vec::new();
2075                 if self.datalen == 0 { return Self::from(res); }
2076                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
2077                 Self::from(res)
2078         }
2079 }
2080 #[repr(C)]
2081 pub struct CVec_NodeAnnouncementZ {
2082         pub data: *mut crate::ln::msgs::NodeAnnouncement,
2083         pub datalen: usize
2084 }
2085 impl CVec_NodeAnnouncementZ {
2086         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::ln::msgs::NodeAnnouncement> {
2087                 if self.datalen == 0 { return Vec::new(); }
2088                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
2089                 self.data = std::ptr::null_mut();
2090                 self.datalen = 0;
2091                 ret
2092         }
2093         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::ln::msgs::NodeAnnouncement] {
2094                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
2095         }
2096 }
2097 impl From<Vec<crate::ln::msgs::NodeAnnouncement>> for CVec_NodeAnnouncementZ {
2098         fn from(v: Vec<crate::ln::msgs::NodeAnnouncement>) -> Self {
2099                 let datalen = v.len();
2100                 let data = Box::into_raw(v.into_boxed_slice());
2101                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
2102         }
2103 }
2104 #[no_mangle]
2105 pub extern "C" fn CVec_NodeAnnouncementZ_free(_res: CVec_NodeAnnouncementZ) { }
2106 impl Drop for CVec_NodeAnnouncementZ {
2107         fn drop(&mut self) {
2108                 if self.datalen == 0 { return; }
2109                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
2110         }
2111 }
2112 impl Clone for CVec_NodeAnnouncementZ {
2113         fn clone(&self) -> Self {
2114                 let mut res = Vec::new();
2115                 if self.datalen == 0 { return Self::from(res); }
2116                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
2117                 Self::from(res)
2118         }
2119 }
2120 #[repr(C)]
2121 pub union CResult_NoneLightningErrorZPtr {
2122         /// Note that this value is always NULL, as there are no contents in the OK variant
2123         pub result: *mut std::ffi::c_void,
2124         pub err: *mut crate::ln::msgs::LightningError,
2125 }
2126 #[repr(C)]
2127 pub struct CResult_NoneLightningErrorZ {
2128         pub contents: CResult_NoneLightningErrorZPtr,
2129         pub result_ok: bool,
2130 }
2131 #[no_mangle]
2132 pub extern "C" fn CResult_NoneLightningErrorZ_ok() -> CResult_NoneLightningErrorZ {
2133         CResult_NoneLightningErrorZ {
2134                 contents: CResult_NoneLightningErrorZPtr {
2135                         result: std::ptr::null_mut(),
2136                 },
2137                 result_ok: true,
2138         }
2139 }
2140 #[no_mangle]
2141 pub extern "C" fn CResult_NoneLightningErrorZ_err(e: crate::ln::msgs::LightningError) -> CResult_NoneLightningErrorZ {
2142         CResult_NoneLightningErrorZ {
2143                 contents: CResult_NoneLightningErrorZPtr {
2144                         err: Box::into_raw(Box::new(e)),
2145                 },
2146                 result_ok: false,
2147         }
2148 }
2149 #[no_mangle]
2150 pub extern "C" fn CResult_NoneLightningErrorZ_free(_res: CResult_NoneLightningErrorZ) { }
2151 impl Drop for CResult_NoneLightningErrorZ {
2152         fn drop(&mut self) {
2153                 if self.result_ok {
2154                 } else {
2155                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
2156                                 let _ = unsafe { Box::from_raw(self.contents.err) };
2157                         }
2158                 }
2159         }
2160 }
2161 impl From<crate::c_types::CResultTempl<u8, crate::ln::msgs::LightningError>> for CResult_NoneLightningErrorZ {
2162         fn from(mut o: crate::c_types::CResultTempl<u8, crate::ln::msgs::LightningError>) -> Self {
2163                 let contents = if o.result_ok {
2164                         let _ = unsafe { Box::from_raw(o.contents.result) };
2165                         o.contents.result = std::ptr::null_mut();
2166                         CResult_NoneLightningErrorZPtr { result: std::ptr::null_mut() }
2167                 } else {
2168                         let err = unsafe { o.contents.err };
2169                         unsafe { o.contents.err = std::ptr::null_mut(); }
2170                         CResult_NoneLightningErrorZPtr { err }
2171                 };
2172                 Self {
2173                         contents,
2174                         result_ok: o.result_ok,
2175                 }
2176         }
2177 }
2178 impl Clone for CResult_NoneLightningErrorZ {
2179         fn clone(&self) -> Self {
2180                 if self.result_ok {
2181                         Self { result_ok: true, contents: CResult_NoneLightningErrorZPtr {
2182                                 result: std::ptr::null_mut()
2183                         } }
2184                 } else {
2185                         Self { result_ok: false, contents: CResult_NoneLightningErrorZPtr {
2186                                 err: Box::into_raw(Box::new(<crate::ln::msgs::LightningError>::clone(unsafe { &*self.contents.err })))
2187                         } }
2188                 }
2189         }
2190 }
2191 #[no_mangle]
2192 pub extern "C" fn CResult_NoneLightningErrorZ_clone(orig: &CResult_NoneLightningErrorZ) -> CResult_NoneLightningErrorZ { orig.clone() }
2193 #[repr(C)]
2194 pub union CResult_ChannelReestablishDecodeErrorZPtr {
2195         pub result: *mut crate::ln::msgs::ChannelReestablish,
2196         pub err: *mut crate::ln::msgs::DecodeError,
2197 }
2198 #[repr(C)]
2199 pub struct CResult_ChannelReestablishDecodeErrorZ {
2200         pub contents: CResult_ChannelReestablishDecodeErrorZPtr,
2201         pub result_ok: bool,
2202 }
2203 #[no_mangle]
2204 pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_ok(o: crate::ln::msgs::ChannelReestablish) -> CResult_ChannelReestablishDecodeErrorZ {
2205         CResult_ChannelReestablishDecodeErrorZ {
2206                 contents: CResult_ChannelReestablishDecodeErrorZPtr {
2207                         result: Box::into_raw(Box::new(o)),
2208                 },
2209                 result_ok: true,
2210         }
2211 }
2212 #[no_mangle]
2213 pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ChannelReestablishDecodeErrorZ {
2214         CResult_ChannelReestablishDecodeErrorZ {
2215                 contents: CResult_ChannelReestablishDecodeErrorZPtr {
2216                         err: Box::into_raw(Box::new(e)),
2217                 },
2218                 result_ok: false,
2219         }
2220 }
2221 #[no_mangle]
2222 pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_free(_res: CResult_ChannelReestablishDecodeErrorZ) { }
2223 impl Drop for CResult_ChannelReestablishDecodeErrorZ {
2224         fn drop(&mut self) {
2225                 if self.result_ok {
2226                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
2227                                 let _ = unsafe { Box::from_raw(self.contents.result) };
2228                         }
2229                 } else {
2230                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
2231                                 let _ = unsafe { Box::from_raw(self.contents.err) };
2232                         }
2233                 }
2234         }
2235 }
2236 impl From<crate::c_types::CResultTempl<crate::ln::msgs::ChannelReestablish, crate::ln::msgs::DecodeError>> for CResult_ChannelReestablishDecodeErrorZ {
2237         fn from(mut o: crate::c_types::CResultTempl<crate::ln::msgs::ChannelReestablish, crate::ln::msgs::DecodeError>) -> Self {
2238                 let contents = if o.result_ok {
2239                         let result = unsafe { o.contents.result };
2240                         unsafe { o.contents.result = std::ptr::null_mut() };
2241                         CResult_ChannelReestablishDecodeErrorZPtr { result }
2242                 } else {
2243                         let err = unsafe { o.contents.err };
2244                         unsafe { o.contents.err = std::ptr::null_mut(); }
2245                         CResult_ChannelReestablishDecodeErrorZPtr { err }
2246                 };
2247                 Self {
2248                         contents,
2249                         result_ok: o.result_ok,
2250                 }
2251         }
2252 }
2253 impl Clone for CResult_ChannelReestablishDecodeErrorZ {
2254         fn clone(&self) -> Self {
2255                 if self.result_ok {
2256                         Self { result_ok: true, contents: CResult_ChannelReestablishDecodeErrorZPtr {
2257                                 result: Box::into_raw(Box::new(<crate::ln::msgs::ChannelReestablish>::clone(unsafe { &*self.contents.result })))
2258                         } }
2259                 } else {
2260                         Self { result_ok: false, contents: CResult_ChannelReestablishDecodeErrorZPtr {
2261                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
2262                         } }
2263                 }
2264         }
2265 }
2266 #[no_mangle]
2267 pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_clone(orig: &CResult_ChannelReestablishDecodeErrorZ) -> CResult_ChannelReestablishDecodeErrorZ { orig.clone() }
2268 #[repr(C)]
2269 pub union CResult_InitDecodeErrorZPtr {
2270         pub result: *mut crate::ln::msgs::Init,
2271         pub err: *mut crate::ln::msgs::DecodeError,
2272 }
2273 #[repr(C)]
2274 pub struct CResult_InitDecodeErrorZ {
2275         pub contents: CResult_InitDecodeErrorZPtr,
2276         pub result_ok: bool,
2277 }
2278 #[no_mangle]
2279 pub extern "C" fn CResult_InitDecodeErrorZ_ok(o: crate::ln::msgs::Init) -> CResult_InitDecodeErrorZ {
2280         CResult_InitDecodeErrorZ {
2281                 contents: CResult_InitDecodeErrorZPtr {
2282                         result: Box::into_raw(Box::new(o)),
2283                 },
2284                 result_ok: true,
2285         }
2286 }
2287 #[no_mangle]
2288 pub extern "C" fn CResult_InitDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_InitDecodeErrorZ {
2289         CResult_InitDecodeErrorZ {
2290                 contents: CResult_InitDecodeErrorZPtr {
2291                         err: Box::into_raw(Box::new(e)),
2292                 },
2293                 result_ok: false,
2294         }
2295 }
2296 #[no_mangle]
2297 pub extern "C" fn CResult_InitDecodeErrorZ_free(_res: CResult_InitDecodeErrorZ) { }
2298 impl Drop for CResult_InitDecodeErrorZ {
2299         fn drop(&mut self) {
2300                 if self.result_ok {
2301                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
2302                                 let _ = unsafe { Box::from_raw(self.contents.result) };
2303                         }
2304                 } else {
2305                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
2306                                 let _ = unsafe { Box::from_raw(self.contents.err) };
2307                         }
2308                 }
2309         }
2310 }
2311 impl From<crate::c_types::CResultTempl<crate::ln::msgs::Init, crate::ln::msgs::DecodeError>> for CResult_InitDecodeErrorZ {
2312         fn from(mut o: crate::c_types::CResultTempl<crate::ln::msgs::Init, crate::ln::msgs::DecodeError>) -> Self {
2313                 let contents = if o.result_ok {
2314                         let result = unsafe { o.contents.result };
2315                         unsafe { o.contents.result = std::ptr::null_mut() };
2316                         CResult_InitDecodeErrorZPtr { result }
2317                 } else {
2318                         let err = unsafe { o.contents.err };
2319                         unsafe { o.contents.err = std::ptr::null_mut(); }
2320                         CResult_InitDecodeErrorZPtr { err }
2321                 };
2322                 Self {
2323                         contents,
2324                         result_ok: o.result_ok,
2325                 }
2326         }
2327 }
2328 impl Clone for CResult_InitDecodeErrorZ {
2329         fn clone(&self) -> Self {
2330                 if self.result_ok {
2331                         Self { result_ok: true, contents: CResult_InitDecodeErrorZPtr {
2332                                 result: Box::into_raw(Box::new(<crate::ln::msgs::Init>::clone(unsafe { &*self.contents.result })))
2333                         } }
2334                 } else {
2335                         Self { result_ok: false, contents: CResult_InitDecodeErrorZPtr {
2336                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
2337                         } }
2338                 }
2339         }
2340 }
2341 #[no_mangle]
2342 pub extern "C" fn CResult_InitDecodeErrorZ_clone(orig: &CResult_InitDecodeErrorZ) -> CResult_InitDecodeErrorZ { orig.clone() }
2343 #[repr(C)]
2344 pub union CResult_PingDecodeErrorZPtr {
2345         pub result: *mut crate::ln::msgs::Ping,
2346         pub err: *mut crate::ln::msgs::DecodeError,
2347 }
2348 #[repr(C)]
2349 pub struct CResult_PingDecodeErrorZ {
2350         pub contents: CResult_PingDecodeErrorZPtr,
2351         pub result_ok: bool,
2352 }
2353 #[no_mangle]
2354 pub extern "C" fn CResult_PingDecodeErrorZ_ok(o: crate::ln::msgs::Ping) -> CResult_PingDecodeErrorZ {
2355         CResult_PingDecodeErrorZ {
2356                 contents: CResult_PingDecodeErrorZPtr {
2357                         result: Box::into_raw(Box::new(o)),
2358                 },
2359                 result_ok: true,
2360         }
2361 }
2362 #[no_mangle]
2363 pub extern "C" fn CResult_PingDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_PingDecodeErrorZ {
2364         CResult_PingDecodeErrorZ {
2365                 contents: CResult_PingDecodeErrorZPtr {
2366                         err: Box::into_raw(Box::new(e)),
2367                 },
2368                 result_ok: false,
2369         }
2370 }
2371 #[no_mangle]
2372 pub extern "C" fn CResult_PingDecodeErrorZ_free(_res: CResult_PingDecodeErrorZ) { }
2373 impl Drop for CResult_PingDecodeErrorZ {
2374         fn drop(&mut self) {
2375                 if self.result_ok {
2376                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
2377                                 let _ = unsafe { Box::from_raw(self.contents.result) };
2378                         }
2379                 } else {
2380                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
2381                                 let _ = unsafe { Box::from_raw(self.contents.err) };
2382                         }
2383                 }
2384         }
2385 }
2386 impl From<crate::c_types::CResultTempl<crate::ln::msgs::Ping, crate::ln::msgs::DecodeError>> for CResult_PingDecodeErrorZ {
2387         fn from(mut o: crate::c_types::CResultTempl<crate::ln::msgs::Ping, crate::ln::msgs::DecodeError>) -> Self {
2388                 let contents = if o.result_ok {
2389                         let result = unsafe { o.contents.result };
2390                         unsafe { o.contents.result = std::ptr::null_mut() };
2391                         CResult_PingDecodeErrorZPtr { result }
2392                 } else {
2393                         let err = unsafe { o.contents.err };
2394                         unsafe { o.contents.err = std::ptr::null_mut(); }
2395                         CResult_PingDecodeErrorZPtr { err }
2396                 };
2397                 Self {
2398                         contents,
2399                         result_ok: o.result_ok,
2400                 }
2401         }
2402 }
2403 impl Clone for CResult_PingDecodeErrorZ {
2404         fn clone(&self) -> Self {
2405                 if self.result_ok {
2406                         Self { result_ok: true, contents: CResult_PingDecodeErrorZPtr {
2407                                 result: Box::into_raw(Box::new(<crate::ln::msgs::Ping>::clone(unsafe { &*self.contents.result })))
2408                         } }
2409                 } else {
2410                         Self { result_ok: false, contents: CResult_PingDecodeErrorZPtr {
2411                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
2412                         } }
2413                 }
2414         }
2415 }
2416 #[no_mangle]
2417 pub extern "C" fn CResult_PingDecodeErrorZ_clone(orig: &CResult_PingDecodeErrorZ) -> CResult_PingDecodeErrorZ { orig.clone() }
2418 #[repr(C)]
2419 pub union CResult_PongDecodeErrorZPtr {
2420         pub result: *mut crate::ln::msgs::Pong,
2421         pub err: *mut crate::ln::msgs::DecodeError,
2422 }
2423 #[repr(C)]
2424 pub struct CResult_PongDecodeErrorZ {
2425         pub contents: CResult_PongDecodeErrorZPtr,
2426         pub result_ok: bool,
2427 }
2428 #[no_mangle]
2429 pub extern "C" fn CResult_PongDecodeErrorZ_ok(o: crate::ln::msgs::Pong) -> CResult_PongDecodeErrorZ {
2430         CResult_PongDecodeErrorZ {
2431                 contents: CResult_PongDecodeErrorZPtr {
2432                         result: Box::into_raw(Box::new(o)),
2433                 },
2434                 result_ok: true,
2435         }
2436 }
2437 #[no_mangle]
2438 pub extern "C" fn CResult_PongDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_PongDecodeErrorZ {
2439         CResult_PongDecodeErrorZ {
2440                 contents: CResult_PongDecodeErrorZPtr {
2441                         err: Box::into_raw(Box::new(e)),
2442                 },
2443                 result_ok: false,
2444         }
2445 }
2446 #[no_mangle]
2447 pub extern "C" fn CResult_PongDecodeErrorZ_free(_res: CResult_PongDecodeErrorZ) { }
2448 impl Drop for CResult_PongDecodeErrorZ {
2449         fn drop(&mut self) {
2450                 if self.result_ok {
2451                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
2452                                 let _ = unsafe { Box::from_raw(self.contents.result) };
2453                         }
2454                 } else {
2455                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
2456                                 let _ = unsafe { Box::from_raw(self.contents.err) };
2457                         }
2458                 }
2459         }
2460 }
2461 impl From<crate::c_types::CResultTempl<crate::ln::msgs::Pong, crate::ln::msgs::DecodeError>> for CResult_PongDecodeErrorZ {
2462         fn from(mut o: crate::c_types::CResultTempl<crate::ln::msgs::Pong, crate::ln::msgs::DecodeError>) -> Self {
2463                 let contents = if o.result_ok {
2464                         let result = unsafe { o.contents.result };
2465                         unsafe { o.contents.result = std::ptr::null_mut() };
2466                         CResult_PongDecodeErrorZPtr { result }
2467                 } else {
2468                         let err = unsafe { o.contents.err };
2469                         unsafe { o.contents.err = std::ptr::null_mut(); }
2470                         CResult_PongDecodeErrorZPtr { err }
2471                 };
2472                 Self {
2473                         contents,
2474                         result_ok: o.result_ok,
2475                 }
2476         }
2477 }
2478 impl Clone for CResult_PongDecodeErrorZ {
2479         fn clone(&self) -> Self {
2480                 if self.result_ok {
2481                         Self { result_ok: true, contents: CResult_PongDecodeErrorZPtr {
2482                                 result: Box::into_raw(Box::new(<crate::ln::msgs::Pong>::clone(unsafe { &*self.contents.result })))
2483                         } }
2484                 } else {
2485                         Self { result_ok: false, contents: CResult_PongDecodeErrorZPtr {
2486                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
2487                         } }
2488                 }
2489         }
2490 }
2491 #[no_mangle]
2492 pub extern "C" fn CResult_PongDecodeErrorZ_clone(orig: &CResult_PongDecodeErrorZ) -> CResult_PongDecodeErrorZ { orig.clone() }
2493 #[repr(C)]
2494 pub union CResult_UnsignedChannelAnnouncementDecodeErrorZPtr {
2495         pub result: *mut crate::ln::msgs::UnsignedChannelAnnouncement,
2496         pub err: *mut crate::ln::msgs::DecodeError,
2497 }
2498 #[repr(C)]
2499 pub struct CResult_UnsignedChannelAnnouncementDecodeErrorZ {
2500         pub contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr,
2501         pub result_ok: bool,
2502 }
2503 #[no_mangle]
2504 pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o: crate::ln::msgs::UnsignedChannelAnnouncement) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ {
2505         CResult_UnsignedChannelAnnouncementDecodeErrorZ {
2506                 contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr {
2507                         result: Box::into_raw(Box::new(o)),
2508                 },
2509                 result_ok: true,
2510         }
2511 }
2512 #[no_mangle]
2513 pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ {
2514         CResult_UnsignedChannelAnnouncementDecodeErrorZ {
2515                 contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr {
2516                         err: Box::into_raw(Box::new(e)),
2517                 },
2518                 result_ok: false,
2519         }
2520 }
2521 #[no_mangle]
2522 pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedChannelAnnouncementDecodeErrorZ) { }
2523 impl Drop for CResult_UnsignedChannelAnnouncementDecodeErrorZ {
2524         fn drop(&mut self) {
2525                 if self.result_ok {
2526                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
2527                                 let _ = unsafe { Box::from_raw(self.contents.result) };
2528                         }
2529                 } else {
2530                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
2531                                 let _ = unsafe { Box::from_raw(self.contents.err) };
2532                         }
2533                 }
2534         }
2535 }
2536 impl From<crate::c_types::CResultTempl<crate::ln::msgs::UnsignedChannelAnnouncement, crate::ln::msgs::DecodeError>> for CResult_UnsignedChannelAnnouncementDecodeErrorZ {
2537         fn from(mut o: crate::c_types::CResultTempl<crate::ln::msgs::UnsignedChannelAnnouncement, crate::ln::msgs::DecodeError>) -> Self {
2538                 let contents = if o.result_ok {
2539                         let result = unsafe { o.contents.result };
2540                         unsafe { o.contents.result = std::ptr::null_mut() };
2541                         CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { result }
2542                 } else {
2543                         let err = unsafe { o.contents.err };
2544                         unsafe { o.contents.err = std::ptr::null_mut(); }
2545                         CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { err }
2546                 };
2547                 Self {
2548                         contents,
2549                         result_ok: o.result_ok,
2550                 }
2551         }
2552 }
2553 impl Clone for CResult_UnsignedChannelAnnouncementDecodeErrorZ {
2554         fn clone(&self) -> Self {
2555                 if self.result_ok {
2556                         Self { result_ok: true, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr {
2557                                 result: Box::into_raw(Box::new(<crate::ln::msgs::UnsignedChannelAnnouncement>::clone(unsafe { &*self.contents.result })))
2558                         } }
2559                 } else {
2560                         Self { result_ok: false, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr {
2561                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
2562                         } }
2563                 }
2564         }
2565 }
2566 #[no_mangle]
2567 pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { orig.clone() }
2568 #[repr(C)]
2569 pub union CResult_UnsignedChannelUpdateDecodeErrorZPtr {
2570         pub result: *mut crate::ln::msgs::UnsignedChannelUpdate,
2571         pub err: *mut crate::ln::msgs::DecodeError,
2572 }
2573 #[repr(C)]
2574 pub struct CResult_UnsignedChannelUpdateDecodeErrorZ {
2575         pub contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr,
2576         pub result_ok: bool,
2577 }
2578 #[no_mangle]
2579 pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o: crate::ln::msgs::UnsignedChannelUpdate) -> CResult_UnsignedChannelUpdateDecodeErrorZ {
2580         CResult_UnsignedChannelUpdateDecodeErrorZ {
2581                 contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr {
2582                         result: Box::into_raw(Box::new(o)),
2583                 },
2584                 result_ok: true,
2585         }
2586 }
2587 #[no_mangle]
2588 pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_UnsignedChannelUpdateDecodeErrorZ {
2589         CResult_UnsignedChannelUpdateDecodeErrorZ {
2590                 contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr {
2591                         err: Box::into_raw(Box::new(e)),
2592                 },
2593                 result_ok: false,
2594         }
2595 }
2596 #[no_mangle]
2597 pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res: CResult_UnsignedChannelUpdateDecodeErrorZ) { }
2598 impl Drop for CResult_UnsignedChannelUpdateDecodeErrorZ {
2599         fn drop(&mut self) {
2600                 if self.result_ok {
2601                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
2602                                 let _ = unsafe { Box::from_raw(self.contents.result) };
2603                         }
2604                 } else {
2605                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
2606                                 let _ = unsafe { Box::from_raw(self.contents.err) };
2607                         }
2608                 }
2609         }
2610 }
2611 impl From<crate::c_types::CResultTempl<crate::ln::msgs::UnsignedChannelUpdate, crate::ln::msgs::DecodeError>> for CResult_UnsignedChannelUpdateDecodeErrorZ {
2612         fn from(mut o: crate::c_types::CResultTempl<crate::ln::msgs::UnsignedChannelUpdate, crate::ln::msgs::DecodeError>) -> Self {
2613                 let contents = if o.result_ok {
2614                         let result = unsafe { o.contents.result };
2615                         unsafe { o.contents.result = std::ptr::null_mut() };
2616                         CResult_UnsignedChannelUpdateDecodeErrorZPtr { result }
2617                 } else {
2618                         let err = unsafe { o.contents.err };
2619                         unsafe { o.contents.err = std::ptr::null_mut(); }
2620                         CResult_UnsignedChannelUpdateDecodeErrorZPtr { err }
2621                 };
2622                 Self {
2623                         contents,
2624                         result_ok: o.result_ok,
2625                 }
2626         }
2627 }
2628 impl Clone for CResult_UnsignedChannelUpdateDecodeErrorZ {
2629         fn clone(&self) -> Self {
2630                 if self.result_ok {
2631                         Self { result_ok: true, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr {
2632                                 result: Box::into_raw(Box::new(<crate::ln::msgs::UnsignedChannelUpdate>::clone(unsafe { &*self.contents.result })))
2633                         } }
2634                 } else {
2635                         Self { result_ok: false, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr {
2636                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
2637                         } }
2638                 }
2639         }
2640 }
2641 #[no_mangle]
2642 pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> CResult_UnsignedChannelUpdateDecodeErrorZ { orig.clone() }
2643 #[repr(C)]
2644 pub union CResult_ErrorMessageDecodeErrorZPtr {
2645         pub result: *mut crate::ln::msgs::ErrorMessage,
2646         pub err: *mut crate::ln::msgs::DecodeError,
2647 }
2648 #[repr(C)]
2649 pub struct CResult_ErrorMessageDecodeErrorZ {
2650         pub contents: CResult_ErrorMessageDecodeErrorZPtr,
2651         pub result_ok: bool,
2652 }
2653 #[no_mangle]
2654 pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_ok(o: crate::ln::msgs::ErrorMessage) -> CResult_ErrorMessageDecodeErrorZ {
2655         CResult_ErrorMessageDecodeErrorZ {
2656                 contents: CResult_ErrorMessageDecodeErrorZPtr {
2657                         result: Box::into_raw(Box::new(o)),
2658                 },
2659                 result_ok: true,
2660         }
2661 }
2662 #[no_mangle]
2663 pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ErrorMessageDecodeErrorZ {
2664         CResult_ErrorMessageDecodeErrorZ {
2665                 contents: CResult_ErrorMessageDecodeErrorZPtr {
2666                         err: Box::into_raw(Box::new(e)),
2667                 },
2668                 result_ok: false,
2669         }
2670 }
2671 #[no_mangle]
2672 pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_free(_res: CResult_ErrorMessageDecodeErrorZ) { }
2673 impl Drop for CResult_ErrorMessageDecodeErrorZ {
2674         fn drop(&mut self) {
2675                 if self.result_ok {
2676                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
2677                                 let _ = unsafe { Box::from_raw(self.contents.result) };
2678                         }
2679                 } else {
2680                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
2681                                 let _ = unsafe { Box::from_raw(self.contents.err) };
2682                         }
2683                 }
2684         }
2685 }
2686 impl From<crate::c_types::CResultTempl<crate::ln::msgs::ErrorMessage, crate::ln::msgs::DecodeError>> for CResult_ErrorMessageDecodeErrorZ {
2687         fn from(mut o: crate::c_types::CResultTempl<crate::ln::msgs::ErrorMessage, crate::ln::msgs::DecodeError>) -> Self {
2688                 let contents = if o.result_ok {
2689                         let result = unsafe { o.contents.result };
2690                         unsafe { o.contents.result = std::ptr::null_mut() };
2691                         CResult_ErrorMessageDecodeErrorZPtr { result }
2692                 } else {
2693                         let err = unsafe { o.contents.err };
2694                         unsafe { o.contents.err = std::ptr::null_mut(); }
2695                         CResult_ErrorMessageDecodeErrorZPtr { err }
2696                 };
2697                 Self {
2698                         contents,
2699                         result_ok: o.result_ok,
2700                 }
2701         }
2702 }
2703 impl Clone for CResult_ErrorMessageDecodeErrorZ {
2704         fn clone(&self) -> Self {
2705                 if self.result_ok {
2706                         Self { result_ok: true, contents: CResult_ErrorMessageDecodeErrorZPtr {
2707                                 result: Box::into_raw(Box::new(<crate::ln::msgs::ErrorMessage>::clone(unsafe { &*self.contents.result })))
2708                         } }
2709                 } else {
2710                         Self { result_ok: false, contents: CResult_ErrorMessageDecodeErrorZPtr {
2711                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
2712                         } }
2713                 }
2714         }
2715 }
2716 #[no_mangle]
2717 pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_clone(orig: &CResult_ErrorMessageDecodeErrorZ) -> CResult_ErrorMessageDecodeErrorZ { orig.clone() }
2718 #[repr(C)]
2719 pub union CResult_UnsignedNodeAnnouncementDecodeErrorZPtr {
2720         pub result: *mut crate::ln::msgs::UnsignedNodeAnnouncement,
2721         pub err: *mut crate::ln::msgs::DecodeError,
2722 }
2723 #[repr(C)]
2724 pub struct CResult_UnsignedNodeAnnouncementDecodeErrorZ {
2725         pub contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr,
2726         pub result_ok: bool,
2727 }
2728 #[no_mangle]
2729 pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o: crate::ln::msgs::UnsignedNodeAnnouncement) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ {
2730         CResult_UnsignedNodeAnnouncementDecodeErrorZ {
2731                 contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr {
2732                         result: Box::into_raw(Box::new(o)),
2733                 },
2734                 result_ok: true,
2735         }
2736 }
2737 #[no_mangle]
2738 pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ {
2739         CResult_UnsignedNodeAnnouncementDecodeErrorZ {
2740                 contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr {
2741                         err: Box::into_raw(Box::new(e)),
2742                 },
2743                 result_ok: false,
2744         }
2745 }
2746 #[no_mangle]
2747 pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedNodeAnnouncementDecodeErrorZ) { }
2748 impl Drop for CResult_UnsignedNodeAnnouncementDecodeErrorZ {
2749         fn drop(&mut self) {
2750                 if self.result_ok {
2751                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
2752                                 let _ = unsafe { Box::from_raw(self.contents.result) };
2753                         }
2754                 } else {
2755                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
2756                                 let _ = unsafe { Box::from_raw(self.contents.err) };
2757                         }
2758                 }
2759         }
2760 }
2761 impl From<crate::c_types::CResultTempl<crate::ln::msgs::UnsignedNodeAnnouncement, crate::ln::msgs::DecodeError>> for CResult_UnsignedNodeAnnouncementDecodeErrorZ {
2762         fn from(mut o: crate::c_types::CResultTempl<crate::ln::msgs::UnsignedNodeAnnouncement, crate::ln::msgs::DecodeError>) -> Self {
2763                 let contents = if o.result_ok {
2764                         let result = unsafe { o.contents.result };
2765                         unsafe { o.contents.result = std::ptr::null_mut() };
2766                         CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { result }
2767                 } else {
2768                         let err = unsafe { o.contents.err };
2769                         unsafe { o.contents.err = std::ptr::null_mut(); }
2770                         CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { err }
2771                 };
2772                 Self {
2773                         contents,
2774                         result_ok: o.result_ok,
2775                 }
2776         }
2777 }
2778 impl Clone for CResult_UnsignedNodeAnnouncementDecodeErrorZ {
2779         fn clone(&self) -> Self {
2780                 if self.result_ok {
2781                         Self { result_ok: true, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr {
2782                                 result: Box::into_raw(Box::new(<crate::ln::msgs::UnsignedNodeAnnouncement>::clone(unsafe { &*self.contents.result })))
2783                         } }
2784                 } else {
2785                         Self { result_ok: false, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr {
2786                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
2787                         } }
2788                 }
2789         }
2790 }
2791 #[no_mangle]
2792 pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedNodeAnnouncementDecodeErrorZ) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { orig.clone() }
2793 #[repr(C)]
2794 pub union CResult_QueryShortChannelIdsDecodeErrorZPtr {
2795         pub result: *mut crate::ln::msgs::QueryShortChannelIds,
2796         pub err: *mut crate::ln::msgs::DecodeError,
2797 }
2798 #[repr(C)]
2799 pub struct CResult_QueryShortChannelIdsDecodeErrorZ {
2800         pub contents: CResult_QueryShortChannelIdsDecodeErrorZPtr,
2801         pub result_ok: bool,
2802 }
2803 #[no_mangle]
2804 pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_ok(o: crate::ln::msgs::QueryShortChannelIds) -> CResult_QueryShortChannelIdsDecodeErrorZ {
2805         CResult_QueryShortChannelIdsDecodeErrorZ {
2806                 contents: CResult_QueryShortChannelIdsDecodeErrorZPtr {
2807                         result: Box::into_raw(Box::new(o)),
2808                 },
2809                 result_ok: true,
2810         }
2811 }
2812 #[no_mangle]
2813 pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_QueryShortChannelIdsDecodeErrorZ {
2814         CResult_QueryShortChannelIdsDecodeErrorZ {
2815                 contents: CResult_QueryShortChannelIdsDecodeErrorZPtr {
2816                         err: Box::into_raw(Box::new(e)),
2817                 },
2818                 result_ok: false,
2819         }
2820 }
2821 #[no_mangle]
2822 pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_free(_res: CResult_QueryShortChannelIdsDecodeErrorZ) { }
2823 impl Drop for CResult_QueryShortChannelIdsDecodeErrorZ {
2824         fn drop(&mut self) {
2825                 if self.result_ok {
2826                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
2827                                 let _ = unsafe { Box::from_raw(self.contents.result) };
2828                         }
2829                 } else {
2830                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
2831                                 let _ = unsafe { Box::from_raw(self.contents.err) };
2832                         }
2833                 }
2834         }
2835 }
2836 impl From<crate::c_types::CResultTempl<crate::ln::msgs::QueryShortChannelIds, crate::ln::msgs::DecodeError>> for CResult_QueryShortChannelIdsDecodeErrorZ {
2837         fn from(mut o: crate::c_types::CResultTempl<crate::ln::msgs::QueryShortChannelIds, crate::ln::msgs::DecodeError>) -> Self {
2838                 let contents = if o.result_ok {
2839                         let result = unsafe { o.contents.result };
2840                         unsafe { o.contents.result = std::ptr::null_mut() };
2841                         CResult_QueryShortChannelIdsDecodeErrorZPtr { result }
2842                 } else {
2843                         let err = unsafe { o.contents.err };
2844                         unsafe { o.contents.err = std::ptr::null_mut(); }
2845                         CResult_QueryShortChannelIdsDecodeErrorZPtr { err }
2846                 };
2847                 Self {
2848                         contents,
2849                         result_ok: o.result_ok,
2850                 }
2851         }
2852 }
2853 impl Clone for CResult_QueryShortChannelIdsDecodeErrorZ {
2854         fn clone(&self) -> Self {
2855                 if self.result_ok {
2856                         Self { result_ok: true, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr {
2857                                 result: Box::into_raw(Box::new(<crate::ln::msgs::QueryShortChannelIds>::clone(unsafe { &*self.contents.result })))
2858                         } }
2859                 } else {
2860                         Self { result_ok: false, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr {
2861                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
2862                         } }
2863                 }
2864         }
2865 }
2866 #[no_mangle]
2867 pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig: &CResult_QueryShortChannelIdsDecodeErrorZ) -> CResult_QueryShortChannelIdsDecodeErrorZ { orig.clone() }
2868 #[repr(C)]
2869 pub union CResult_ReplyShortChannelIdsEndDecodeErrorZPtr {
2870         pub result: *mut crate::ln::msgs::ReplyShortChannelIdsEnd,
2871         pub err: *mut crate::ln::msgs::DecodeError,
2872 }
2873 #[repr(C)]
2874 pub struct CResult_ReplyShortChannelIdsEndDecodeErrorZ {
2875         pub contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr,
2876         pub result_ok: bool,
2877 }
2878 #[no_mangle]
2879 pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o: crate::ln::msgs::ReplyShortChannelIdsEnd) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ {
2880         CResult_ReplyShortChannelIdsEndDecodeErrorZ {
2881                 contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr {
2882                         result: Box::into_raw(Box::new(o)),
2883                 },
2884                 result_ok: true,
2885         }
2886 }
2887 #[no_mangle]
2888 pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ {
2889         CResult_ReplyShortChannelIdsEndDecodeErrorZ {
2890                 contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr {
2891                         err: Box::into_raw(Box::new(e)),
2892                 },
2893                 result_ok: false,
2894         }
2895 }
2896 #[no_mangle]
2897 pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res: CResult_ReplyShortChannelIdsEndDecodeErrorZ) { }
2898 impl Drop for CResult_ReplyShortChannelIdsEndDecodeErrorZ {
2899         fn drop(&mut self) {
2900                 if self.result_ok {
2901                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
2902                                 let _ = unsafe { Box::from_raw(self.contents.result) };
2903                         }
2904                 } else {
2905                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
2906                                 let _ = unsafe { Box::from_raw(self.contents.err) };
2907                         }
2908                 }
2909         }
2910 }
2911 impl From<crate::c_types::CResultTempl<crate::ln::msgs::ReplyShortChannelIdsEnd, crate::ln::msgs::DecodeError>> for CResult_ReplyShortChannelIdsEndDecodeErrorZ {
2912         fn from(mut o: crate::c_types::CResultTempl<crate::ln::msgs::ReplyShortChannelIdsEnd, crate::ln::msgs::DecodeError>) -> Self {
2913                 let contents = if o.result_ok {
2914                         let result = unsafe { o.contents.result };
2915                         unsafe { o.contents.result = std::ptr::null_mut() };
2916                         CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { result }
2917                 } else {
2918                         let err = unsafe { o.contents.err };
2919                         unsafe { o.contents.err = std::ptr::null_mut(); }
2920                         CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { err }
2921                 };
2922                 Self {
2923                         contents,
2924                         result_ok: o.result_ok,
2925                 }
2926         }
2927 }
2928 impl Clone for CResult_ReplyShortChannelIdsEndDecodeErrorZ {
2929         fn clone(&self) -> Self {
2930                 if self.result_ok {
2931                         Self { result_ok: true, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr {
2932                                 result: Box::into_raw(Box::new(<crate::ln::msgs::ReplyShortChannelIdsEnd>::clone(unsafe { &*self.contents.result })))
2933                         } }
2934                 } else {
2935                         Self { result_ok: false, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr {
2936                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
2937                         } }
2938                 }
2939         }
2940 }
2941 #[no_mangle]
2942 pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { orig.clone() }
2943 #[repr(C)]
2944 pub union CResult_QueryChannelRangeDecodeErrorZPtr {
2945         pub result: *mut crate::ln::msgs::QueryChannelRange,
2946         pub err: *mut crate::ln::msgs::DecodeError,
2947 }
2948 #[repr(C)]
2949 pub struct CResult_QueryChannelRangeDecodeErrorZ {
2950         pub contents: CResult_QueryChannelRangeDecodeErrorZPtr,
2951         pub result_ok: bool,
2952 }
2953 #[no_mangle]
2954 pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_ok(o: crate::ln::msgs::QueryChannelRange) -> CResult_QueryChannelRangeDecodeErrorZ {
2955         CResult_QueryChannelRangeDecodeErrorZ {
2956                 contents: CResult_QueryChannelRangeDecodeErrorZPtr {
2957                         result: Box::into_raw(Box::new(o)),
2958                 },
2959                 result_ok: true,
2960         }
2961 }
2962 #[no_mangle]
2963 pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_QueryChannelRangeDecodeErrorZ {
2964         CResult_QueryChannelRangeDecodeErrorZ {
2965                 contents: CResult_QueryChannelRangeDecodeErrorZPtr {
2966                         err: Box::into_raw(Box::new(e)),
2967                 },
2968                 result_ok: false,
2969         }
2970 }
2971 #[no_mangle]
2972 pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_free(_res: CResult_QueryChannelRangeDecodeErrorZ) { }
2973 impl Drop for CResult_QueryChannelRangeDecodeErrorZ {
2974         fn drop(&mut self) {
2975                 if self.result_ok {
2976                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
2977                                 let _ = unsafe { Box::from_raw(self.contents.result) };
2978                         }
2979                 } else {
2980                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
2981                                 let _ = unsafe { Box::from_raw(self.contents.err) };
2982                         }
2983                 }
2984         }
2985 }
2986 impl From<crate::c_types::CResultTempl<crate::ln::msgs::QueryChannelRange, crate::ln::msgs::DecodeError>> for CResult_QueryChannelRangeDecodeErrorZ {
2987         fn from(mut o: crate::c_types::CResultTempl<crate::ln::msgs::QueryChannelRange, crate::ln::msgs::DecodeError>) -> Self {
2988                 let contents = if o.result_ok {
2989                         let result = unsafe { o.contents.result };
2990                         unsafe { o.contents.result = std::ptr::null_mut() };
2991                         CResult_QueryChannelRangeDecodeErrorZPtr { result }
2992                 } else {
2993                         let err = unsafe { o.contents.err };
2994                         unsafe { o.contents.err = std::ptr::null_mut(); }
2995                         CResult_QueryChannelRangeDecodeErrorZPtr { err }
2996                 };
2997                 Self {
2998                         contents,
2999                         result_ok: o.result_ok,
3000                 }
3001         }
3002 }
3003 impl Clone for CResult_QueryChannelRangeDecodeErrorZ {
3004         fn clone(&self) -> Self {
3005                 if self.result_ok {
3006                         Self { result_ok: true, contents: CResult_QueryChannelRangeDecodeErrorZPtr {
3007                                 result: Box::into_raw(Box::new(<crate::ln::msgs::QueryChannelRange>::clone(unsafe { &*self.contents.result })))
3008                         } }
3009                 } else {
3010                         Self { result_ok: false, contents: CResult_QueryChannelRangeDecodeErrorZPtr {
3011                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
3012                         } }
3013                 }
3014         }
3015 }
3016 #[no_mangle]
3017 pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_clone(orig: &CResult_QueryChannelRangeDecodeErrorZ) -> CResult_QueryChannelRangeDecodeErrorZ { orig.clone() }
3018 #[repr(C)]
3019 pub union CResult_ReplyChannelRangeDecodeErrorZPtr {
3020         pub result: *mut crate::ln::msgs::ReplyChannelRange,
3021         pub err: *mut crate::ln::msgs::DecodeError,
3022 }
3023 #[repr(C)]
3024 pub struct CResult_ReplyChannelRangeDecodeErrorZ {
3025         pub contents: CResult_ReplyChannelRangeDecodeErrorZPtr,
3026         pub result_ok: bool,
3027 }
3028 #[no_mangle]
3029 pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_ok(o: crate::ln::msgs::ReplyChannelRange) -> CResult_ReplyChannelRangeDecodeErrorZ {
3030         CResult_ReplyChannelRangeDecodeErrorZ {
3031                 contents: CResult_ReplyChannelRangeDecodeErrorZPtr {
3032                         result: Box::into_raw(Box::new(o)),
3033                 },
3034                 result_ok: true,
3035         }
3036 }
3037 #[no_mangle]
3038 pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ReplyChannelRangeDecodeErrorZ {
3039         CResult_ReplyChannelRangeDecodeErrorZ {
3040                 contents: CResult_ReplyChannelRangeDecodeErrorZPtr {
3041                         err: Box::into_raw(Box::new(e)),
3042                 },
3043                 result_ok: false,
3044         }
3045 }
3046 #[no_mangle]
3047 pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_free(_res: CResult_ReplyChannelRangeDecodeErrorZ) { }
3048 impl Drop for CResult_ReplyChannelRangeDecodeErrorZ {
3049         fn drop(&mut self) {
3050                 if self.result_ok {
3051                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
3052                                 let _ = unsafe { Box::from_raw(self.contents.result) };
3053                         }
3054                 } else {
3055                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
3056                                 let _ = unsafe { Box::from_raw(self.contents.err) };
3057                         }
3058                 }
3059         }
3060 }
3061 impl From<crate::c_types::CResultTempl<crate::ln::msgs::ReplyChannelRange, crate::ln::msgs::DecodeError>> for CResult_ReplyChannelRangeDecodeErrorZ {
3062         fn from(mut o: crate::c_types::CResultTempl<crate::ln::msgs::ReplyChannelRange, crate::ln::msgs::DecodeError>) -> Self {
3063                 let contents = if o.result_ok {
3064                         let result = unsafe { o.contents.result };
3065                         unsafe { o.contents.result = std::ptr::null_mut() };
3066                         CResult_ReplyChannelRangeDecodeErrorZPtr { result }
3067                 } else {
3068                         let err = unsafe { o.contents.err };
3069                         unsafe { o.contents.err = std::ptr::null_mut(); }
3070                         CResult_ReplyChannelRangeDecodeErrorZPtr { err }
3071                 };
3072                 Self {
3073                         contents,
3074                         result_ok: o.result_ok,
3075                 }
3076         }
3077 }
3078 impl Clone for CResult_ReplyChannelRangeDecodeErrorZ {
3079         fn clone(&self) -> Self {
3080                 if self.result_ok {
3081                         Self { result_ok: true, contents: CResult_ReplyChannelRangeDecodeErrorZPtr {
3082                                 result: Box::into_raw(Box::new(<crate::ln::msgs::ReplyChannelRange>::clone(unsafe { &*self.contents.result })))
3083                         } }
3084                 } else {
3085                         Self { result_ok: false, contents: CResult_ReplyChannelRangeDecodeErrorZPtr {
3086                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
3087                         } }
3088                 }
3089         }
3090 }
3091 #[no_mangle]
3092 pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_clone(orig: &CResult_ReplyChannelRangeDecodeErrorZ) -> CResult_ReplyChannelRangeDecodeErrorZ { orig.clone() }
3093 #[repr(C)]
3094 pub union CResult_GossipTimestampFilterDecodeErrorZPtr {
3095         pub result: *mut crate::ln::msgs::GossipTimestampFilter,
3096         pub err: *mut crate::ln::msgs::DecodeError,
3097 }
3098 #[repr(C)]
3099 pub struct CResult_GossipTimestampFilterDecodeErrorZ {
3100         pub contents: CResult_GossipTimestampFilterDecodeErrorZPtr,
3101         pub result_ok: bool,
3102 }
3103 #[no_mangle]
3104 pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_ok(o: crate::ln::msgs::GossipTimestampFilter) -> CResult_GossipTimestampFilterDecodeErrorZ {
3105         CResult_GossipTimestampFilterDecodeErrorZ {
3106                 contents: CResult_GossipTimestampFilterDecodeErrorZPtr {
3107                         result: Box::into_raw(Box::new(o)),
3108                 },
3109                 result_ok: true,
3110         }
3111 }
3112 #[no_mangle]
3113 pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_GossipTimestampFilterDecodeErrorZ {
3114         CResult_GossipTimestampFilterDecodeErrorZ {
3115                 contents: CResult_GossipTimestampFilterDecodeErrorZPtr {
3116                         err: Box::into_raw(Box::new(e)),
3117                 },
3118                 result_ok: false,
3119         }
3120 }
3121 #[no_mangle]
3122 pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_free(_res: CResult_GossipTimestampFilterDecodeErrorZ) { }
3123 impl Drop for CResult_GossipTimestampFilterDecodeErrorZ {
3124         fn drop(&mut self) {
3125                 if self.result_ok {
3126                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
3127                                 let _ = unsafe { Box::from_raw(self.contents.result) };
3128                         }
3129                 } else {
3130                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
3131                                 let _ = unsafe { Box::from_raw(self.contents.err) };
3132                         }
3133                 }
3134         }
3135 }
3136 impl From<crate::c_types::CResultTempl<crate::ln::msgs::GossipTimestampFilter, crate::ln::msgs::DecodeError>> for CResult_GossipTimestampFilterDecodeErrorZ {
3137         fn from(mut o: crate::c_types::CResultTempl<crate::ln::msgs::GossipTimestampFilter, crate::ln::msgs::DecodeError>) -> Self {
3138                 let contents = if o.result_ok {
3139                         let result = unsafe { o.contents.result };
3140                         unsafe { o.contents.result = std::ptr::null_mut() };
3141                         CResult_GossipTimestampFilterDecodeErrorZPtr { result }
3142                 } else {
3143                         let err = unsafe { o.contents.err };
3144                         unsafe { o.contents.err = std::ptr::null_mut(); }
3145                         CResult_GossipTimestampFilterDecodeErrorZPtr { err }
3146                 };
3147                 Self {
3148                         contents,
3149                         result_ok: o.result_ok,
3150                 }
3151         }
3152 }
3153 impl Clone for CResult_GossipTimestampFilterDecodeErrorZ {
3154         fn clone(&self) -> Self {
3155                 if self.result_ok {
3156                         Self { result_ok: true, contents: CResult_GossipTimestampFilterDecodeErrorZPtr {
3157                                 result: Box::into_raw(Box::new(<crate::ln::msgs::GossipTimestampFilter>::clone(unsafe { &*self.contents.result })))
3158                         } }
3159                 } else {
3160                         Self { result_ok: false, contents: CResult_GossipTimestampFilterDecodeErrorZPtr {
3161                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
3162                         } }
3163                 }
3164         }
3165 }
3166 #[no_mangle]
3167 pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_clone(orig: &CResult_GossipTimestampFilterDecodeErrorZ) -> CResult_GossipTimestampFilterDecodeErrorZ { orig.clone() }
3168 #[repr(C)]
3169 pub struct CVec_PublicKeyZ {
3170         pub data: *mut crate::c_types::PublicKey,
3171         pub datalen: usize
3172 }
3173 impl CVec_PublicKeyZ {
3174         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::PublicKey> {
3175                 if self.datalen == 0 { return Vec::new(); }
3176                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
3177                 self.data = std::ptr::null_mut();
3178                 self.datalen = 0;
3179                 ret
3180         }
3181         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::PublicKey] {
3182                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
3183         }
3184 }
3185 impl From<Vec<crate::c_types::PublicKey>> for CVec_PublicKeyZ {
3186         fn from(v: Vec<crate::c_types::PublicKey>) -> Self {
3187                 let datalen = v.len();
3188                 let data = Box::into_raw(v.into_boxed_slice());
3189                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
3190         }
3191 }
3192 #[no_mangle]
3193 pub extern "C" fn CVec_PublicKeyZ_free(_res: CVec_PublicKeyZ) { }
3194 impl Drop for CVec_PublicKeyZ {
3195         fn drop(&mut self) {
3196                 if self.datalen == 0 { return; }
3197                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
3198         }
3199 }
3200 #[repr(C)]
3201 pub struct CVec_u8Z {
3202         pub data: *mut u8,
3203         pub datalen: usize
3204 }
3205 impl CVec_u8Z {
3206         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<u8> {
3207                 if self.datalen == 0 { return Vec::new(); }
3208                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
3209                 self.data = std::ptr::null_mut();
3210                 self.datalen = 0;
3211                 ret
3212         }
3213         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u8] {
3214                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
3215         }
3216 }
3217 impl From<Vec<u8>> for CVec_u8Z {
3218         fn from(v: Vec<u8>) -> Self {
3219                 let datalen = v.len();
3220                 let data = Box::into_raw(v.into_boxed_slice());
3221                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
3222         }
3223 }
3224 #[no_mangle]
3225 pub extern "C" fn CVec_u8Z_free(_res: CVec_u8Z) { }
3226 impl Drop for CVec_u8Z {
3227         fn drop(&mut self) {
3228                 if self.datalen == 0 { return; }
3229                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
3230         }
3231 }
3232 impl Clone for CVec_u8Z {
3233         fn clone(&self) -> Self {
3234                 let mut res = Vec::new();
3235                 if self.datalen == 0 { return Self::from(res); }
3236                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
3237                 Self::from(res)
3238         }
3239 }
3240 #[repr(C)]
3241 pub union CResult_CVec_u8ZPeerHandleErrorZPtr {
3242         pub result: *mut crate::c_types::derived::CVec_u8Z,
3243         pub err: *mut crate::ln::peer_handler::PeerHandleError,
3244 }
3245 #[repr(C)]
3246 pub struct CResult_CVec_u8ZPeerHandleErrorZ {
3247         pub contents: CResult_CVec_u8ZPeerHandleErrorZPtr,
3248         pub result_ok: bool,
3249 }
3250 #[no_mangle]
3251 pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_CVec_u8ZPeerHandleErrorZ {
3252         CResult_CVec_u8ZPeerHandleErrorZ {
3253                 contents: CResult_CVec_u8ZPeerHandleErrorZPtr {
3254                         result: Box::into_raw(Box::new(o)),
3255                 },
3256                 result_ok: true,
3257         }
3258 }
3259 #[no_mangle]
3260 pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_err(e: crate::ln::peer_handler::PeerHandleError) -> CResult_CVec_u8ZPeerHandleErrorZ {
3261         CResult_CVec_u8ZPeerHandleErrorZ {
3262                 contents: CResult_CVec_u8ZPeerHandleErrorZPtr {
3263                         err: Box::into_raw(Box::new(e)),
3264                 },
3265                 result_ok: false,
3266         }
3267 }
3268 #[no_mangle]
3269 pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_free(_res: CResult_CVec_u8ZPeerHandleErrorZ) { }
3270 impl Drop for CResult_CVec_u8ZPeerHandleErrorZ {
3271         fn drop(&mut self) {
3272                 if self.result_ok {
3273                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
3274                                 let _ = unsafe { Box::from_raw(self.contents.result) };
3275                         }
3276                 } else {
3277                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
3278                                 let _ = unsafe { Box::from_raw(self.contents.err) };
3279                         }
3280                 }
3281         }
3282 }
3283 impl From<crate::c_types::CResultTempl<crate::c_types::derived::CVec_u8Z, crate::ln::peer_handler::PeerHandleError>> for CResult_CVec_u8ZPeerHandleErrorZ {
3284         fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::CVec_u8Z, crate::ln::peer_handler::PeerHandleError>) -> Self {
3285                 let contents = if o.result_ok {
3286                         let result = unsafe { o.contents.result };
3287                         unsafe { o.contents.result = std::ptr::null_mut() };
3288                         CResult_CVec_u8ZPeerHandleErrorZPtr { result }
3289                 } else {
3290                         let err = unsafe { o.contents.err };
3291                         unsafe { o.contents.err = std::ptr::null_mut(); }
3292                         CResult_CVec_u8ZPeerHandleErrorZPtr { err }
3293                 };
3294                 Self {
3295                         contents,
3296                         result_ok: o.result_ok,
3297                 }
3298         }
3299 }
3300 impl Clone for CResult_CVec_u8ZPeerHandleErrorZ {
3301         fn clone(&self) -> Self {
3302                 if self.result_ok {
3303                         Self { result_ok: true, contents: CResult_CVec_u8ZPeerHandleErrorZPtr {
3304                                 result: Box::into_raw(Box::new(<crate::c_types::derived::CVec_u8Z>::clone(unsafe { &*self.contents.result })))
3305                         } }
3306                 } else {
3307                         Self { result_ok: false, contents: CResult_CVec_u8ZPeerHandleErrorZPtr {
3308                                 err: Box::into_raw(Box::new(<crate::ln::peer_handler::PeerHandleError>::clone(unsafe { &*self.contents.err })))
3309                         } }
3310                 }
3311         }
3312 }
3313 #[no_mangle]
3314 pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_clone(orig: &CResult_CVec_u8ZPeerHandleErrorZ) -> CResult_CVec_u8ZPeerHandleErrorZ { orig.clone() }
3315 #[repr(C)]
3316 pub union CResult_NonePeerHandleErrorZPtr {
3317         /// Note that this value is always NULL, as there are no contents in the OK variant
3318         pub result: *mut std::ffi::c_void,
3319         pub err: *mut crate::ln::peer_handler::PeerHandleError,
3320 }
3321 #[repr(C)]
3322 pub struct CResult_NonePeerHandleErrorZ {
3323         pub contents: CResult_NonePeerHandleErrorZPtr,
3324         pub result_ok: bool,
3325 }
3326 #[no_mangle]
3327 pub extern "C" fn CResult_NonePeerHandleErrorZ_ok() -> CResult_NonePeerHandleErrorZ {
3328         CResult_NonePeerHandleErrorZ {
3329                 contents: CResult_NonePeerHandleErrorZPtr {
3330                         result: std::ptr::null_mut(),
3331                 },
3332                 result_ok: true,
3333         }
3334 }
3335 #[no_mangle]
3336 pub extern "C" fn CResult_NonePeerHandleErrorZ_err(e: crate::ln::peer_handler::PeerHandleError) -> CResult_NonePeerHandleErrorZ {
3337         CResult_NonePeerHandleErrorZ {
3338                 contents: CResult_NonePeerHandleErrorZPtr {
3339                         err: Box::into_raw(Box::new(e)),
3340                 },
3341                 result_ok: false,
3342         }
3343 }
3344 #[no_mangle]
3345 pub extern "C" fn CResult_NonePeerHandleErrorZ_free(_res: CResult_NonePeerHandleErrorZ) { }
3346 impl Drop for CResult_NonePeerHandleErrorZ {
3347         fn drop(&mut self) {
3348                 if self.result_ok {
3349                 } else {
3350                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
3351                                 let _ = unsafe { Box::from_raw(self.contents.err) };
3352                         }
3353                 }
3354         }
3355 }
3356 impl From<crate::c_types::CResultTempl<u8, crate::ln::peer_handler::PeerHandleError>> for CResult_NonePeerHandleErrorZ {
3357         fn from(mut o: crate::c_types::CResultTempl<u8, crate::ln::peer_handler::PeerHandleError>) -> Self {
3358                 let contents = if o.result_ok {
3359                         let _ = unsafe { Box::from_raw(o.contents.result) };
3360                         o.contents.result = std::ptr::null_mut();
3361                         CResult_NonePeerHandleErrorZPtr { result: std::ptr::null_mut() }
3362                 } else {
3363                         let err = unsafe { o.contents.err };
3364                         unsafe { o.contents.err = std::ptr::null_mut(); }
3365                         CResult_NonePeerHandleErrorZPtr { err }
3366                 };
3367                 Self {
3368                         contents,
3369                         result_ok: o.result_ok,
3370                 }
3371         }
3372 }
3373 impl Clone for CResult_NonePeerHandleErrorZ {
3374         fn clone(&self) -> Self {
3375                 if self.result_ok {
3376                         Self { result_ok: true, contents: CResult_NonePeerHandleErrorZPtr {
3377                                 result: std::ptr::null_mut()
3378                         } }
3379                 } else {
3380                         Self { result_ok: false, contents: CResult_NonePeerHandleErrorZPtr {
3381                                 err: Box::into_raw(Box::new(<crate::ln::peer_handler::PeerHandleError>::clone(unsafe { &*self.contents.err })))
3382                         } }
3383                 }
3384         }
3385 }
3386 #[no_mangle]
3387 pub extern "C" fn CResult_NonePeerHandleErrorZ_clone(orig: &CResult_NonePeerHandleErrorZ) -> CResult_NonePeerHandleErrorZ { orig.clone() }
3388 #[repr(C)]
3389 pub union CResult_boolPeerHandleErrorZPtr {
3390         pub result: *mut bool,
3391         pub err: *mut crate::ln::peer_handler::PeerHandleError,
3392 }
3393 #[repr(C)]
3394 pub struct CResult_boolPeerHandleErrorZ {
3395         pub contents: CResult_boolPeerHandleErrorZPtr,
3396         pub result_ok: bool,
3397 }
3398 #[no_mangle]
3399 pub extern "C" fn CResult_boolPeerHandleErrorZ_ok(o: bool) -> CResult_boolPeerHandleErrorZ {
3400         CResult_boolPeerHandleErrorZ {
3401                 contents: CResult_boolPeerHandleErrorZPtr {
3402                         result: Box::into_raw(Box::new(o)),
3403                 },
3404                 result_ok: true,
3405         }
3406 }
3407 #[no_mangle]
3408 pub extern "C" fn CResult_boolPeerHandleErrorZ_err(e: crate::ln::peer_handler::PeerHandleError) -> CResult_boolPeerHandleErrorZ {
3409         CResult_boolPeerHandleErrorZ {
3410                 contents: CResult_boolPeerHandleErrorZPtr {
3411                         err: Box::into_raw(Box::new(e)),
3412                 },
3413                 result_ok: false,
3414         }
3415 }
3416 #[no_mangle]
3417 pub extern "C" fn CResult_boolPeerHandleErrorZ_free(_res: CResult_boolPeerHandleErrorZ) { }
3418 impl Drop for CResult_boolPeerHandleErrorZ {
3419         fn drop(&mut self) {
3420                 if self.result_ok {
3421                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
3422                                 let _ = unsafe { Box::from_raw(self.contents.result) };
3423                         }
3424                 } else {
3425                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
3426                                 let _ = unsafe { Box::from_raw(self.contents.err) };
3427                         }
3428                 }
3429         }
3430 }
3431 impl From<crate::c_types::CResultTempl<bool, crate::ln::peer_handler::PeerHandleError>> for CResult_boolPeerHandleErrorZ {
3432         fn from(mut o: crate::c_types::CResultTempl<bool, crate::ln::peer_handler::PeerHandleError>) -> Self {
3433                 let contents = if o.result_ok {
3434                         let result = unsafe { o.contents.result };
3435                         unsafe { o.contents.result = std::ptr::null_mut() };
3436                         CResult_boolPeerHandleErrorZPtr { result }
3437                 } else {
3438                         let err = unsafe { o.contents.err };
3439                         unsafe { o.contents.err = std::ptr::null_mut(); }
3440                         CResult_boolPeerHandleErrorZPtr { err }
3441                 };
3442                 Self {
3443                         contents,
3444                         result_ok: o.result_ok,
3445                 }
3446         }
3447 }
3448 impl Clone for CResult_boolPeerHandleErrorZ {
3449         fn clone(&self) -> Self {
3450                 if self.result_ok {
3451                         Self { result_ok: true, contents: CResult_boolPeerHandleErrorZPtr {
3452                                 result: Box::into_raw(Box::new(<bool>::clone(unsafe { &*self.contents.result })))
3453                         } }
3454                 } else {
3455                         Self { result_ok: false, contents: CResult_boolPeerHandleErrorZPtr {
3456                                 err: Box::into_raw(Box::new(<crate::ln::peer_handler::PeerHandleError>::clone(unsafe { &*self.contents.err })))
3457                         } }
3458                 }
3459         }
3460 }
3461 #[no_mangle]
3462 pub extern "C" fn CResult_boolPeerHandleErrorZ_clone(orig: &CResult_boolPeerHandleErrorZ) -> CResult_boolPeerHandleErrorZ { orig.clone() }
3463 #[repr(C)]
3464 pub union CResult_SecretKeySecpErrorZPtr {
3465         pub result: *mut crate::c_types::SecretKey,
3466         pub err: *mut crate::c_types::Secp256k1Error,
3467 }
3468 #[repr(C)]
3469 pub struct CResult_SecretKeySecpErrorZ {
3470         pub contents: CResult_SecretKeySecpErrorZPtr,
3471         pub result_ok: bool,
3472 }
3473 #[no_mangle]
3474 pub extern "C" fn CResult_SecretKeySecpErrorZ_ok(o: crate::c_types::SecretKey) -> CResult_SecretKeySecpErrorZ {
3475         CResult_SecretKeySecpErrorZ {
3476                 contents: CResult_SecretKeySecpErrorZPtr {
3477                         result: Box::into_raw(Box::new(o)),
3478                 },
3479                 result_ok: true,
3480         }
3481 }
3482 #[no_mangle]
3483 pub extern "C" fn CResult_SecretKeySecpErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_SecretKeySecpErrorZ {
3484         CResult_SecretKeySecpErrorZ {
3485                 contents: CResult_SecretKeySecpErrorZPtr {
3486                         err: Box::into_raw(Box::new(e)),
3487                 },
3488                 result_ok: false,
3489         }
3490 }
3491 #[no_mangle]
3492 pub extern "C" fn CResult_SecretKeySecpErrorZ_free(_res: CResult_SecretKeySecpErrorZ) { }
3493 impl Drop for CResult_SecretKeySecpErrorZ {
3494         fn drop(&mut self) {
3495                 if self.result_ok {
3496                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
3497                                 let _ = unsafe { Box::from_raw(self.contents.result) };
3498                         }
3499                 } else {
3500                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
3501                                 let _ = unsafe { Box::from_raw(self.contents.err) };
3502                         }
3503                 }
3504         }
3505 }
3506 impl From<crate::c_types::CResultTempl<crate::c_types::SecretKey, crate::c_types::Secp256k1Error>> for CResult_SecretKeySecpErrorZ {
3507         fn from(mut o: crate::c_types::CResultTempl<crate::c_types::SecretKey, crate::c_types::Secp256k1Error>) -> Self {
3508                 let contents = if o.result_ok {
3509                         let result = unsafe { o.contents.result };
3510                         unsafe { o.contents.result = std::ptr::null_mut() };
3511                         CResult_SecretKeySecpErrorZPtr { result }
3512                 } else {
3513                         let err = unsafe { o.contents.err };
3514                         unsafe { o.contents.err = std::ptr::null_mut(); }
3515                         CResult_SecretKeySecpErrorZPtr { err }
3516                 };
3517                 Self {
3518                         contents,
3519                         result_ok: o.result_ok,
3520                 }
3521         }
3522 }
3523 #[repr(C)]
3524 pub union CResult_PublicKeySecpErrorZPtr {
3525         pub result: *mut crate::c_types::PublicKey,
3526         pub err: *mut crate::c_types::Secp256k1Error,
3527 }
3528 #[repr(C)]
3529 pub struct CResult_PublicKeySecpErrorZ {
3530         pub contents: CResult_PublicKeySecpErrorZPtr,
3531         pub result_ok: bool,
3532 }
3533 #[no_mangle]
3534 pub extern "C" fn CResult_PublicKeySecpErrorZ_ok(o: crate::c_types::PublicKey) -> CResult_PublicKeySecpErrorZ {
3535         CResult_PublicKeySecpErrorZ {
3536                 contents: CResult_PublicKeySecpErrorZPtr {
3537                         result: Box::into_raw(Box::new(o)),
3538                 },
3539                 result_ok: true,
3540         }
3541 }
3542 #[no_mangle]
3543 pub extern "C" fn CResult_PublicKeySecpErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_PublicKeySecpErrorZ {
3544         CResult_PublicKeySecpErrorZ {
3545                 contents: CResult_PublicKeySecpErrorZPtr {
3546                         err: Box::into_raw(Box::new(e)),
3547                 },
3548                 result_ok: false,
3549         }
3550 }
3551 #[no_mangle]
3552 pub extern "C" fn CResult_PublicKeySecpErrorZ_free(_res: CResult_PublicKeySecpErrorZ) { }
3553 impl Drop for CResult_PublicKeySecpErrorZ {
3554         fn drop(&mut self) {
3555                 if self.result_ok {
3556                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
3557                                 let _ = unsafe { Box::from_raw(self.contents.result) };
3558                         }
3559                 } else {
3560                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
3561                                 let _ = unsafe { Box::from_raw(self.contents.err) };
3562                         }
3563                 }
3564         }
3565 }
3566 impl From<crate::c_types::CResultTempl<crate::c_types::PublicKey, crate::c_types::Secp256k1Error>> for CResult_PublicKeySecpErrorZ {
3567         fn from(mut o: crate::c_types::CResultTempl<crate::c_types::PublicKey, crate::c_types::Secp256k1Error>) -> Self {
3568                 let contents = if o.result_ok {
3569                         let result = unsafe { o.contents.result };
3570                         unsafe { o.contents.result = std::ptr::null_mut() };
3571                         CResult_PublicKeySecpErrorZPtr { result }
3572                 } else {
3573                         let err = unsafe { o.contents.err };
3574                         unsafe { o.contents.err = std::ptr::null_mut(); }
3575                         CResult_PublicKeySecpErrorZPtr { err }
3576                 };
3577                 Self {
3578                         contents,
3579                         result_ok: o.result_ok,
3580                 }
3581         }
3582 }
3583 #[repr(C)]
3584 pub union CResult_TxCreationKeysSecpErrorZPtr {
3585         pub result: *mut crate::ln::chan_utils::TxCreationKeys,
3586         pub err: *mut crate::c_types::Secp256k1Error,
3587 }
3588 #[repr(C)]
3589 pub struct CResult_TxCreationKeysSecpErrorZ {
3590         pub contents: CResult_TxCreationKeysSecpErrorZPtr,
3591         pub result_ok: bool,
3592 }
3593 #[no_mangle]
3594 pub extern "C" fn CResult_TxCreationKeysSecpErrorZ_ok(o: crate::ln::chan_utils::TxCreationKeys) -> CResult_TxCreationKeysSecpErrorZ {
3595         CResult_TxCreationKeysSecpErrorZ {
3596                 contents: CResult_TxCreationKeysSecpErrorZPtr {
3597                         result: Box::into_raw(Box::new(o)),
3598                 },
3599                 result_ok: true,
3600         }
3601 }
3602 #[no_mangle]
3603 pub extern "C" fn CResult_TxCreationKeysSecpErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_TxCreationKeysSecpErrorZ {
3604         CResult_TxCreationKeysSecpErrorZ {
3605                 contents: CResult_TxCreationKeysSecpErrorZPtr {
3606                         err: Box::into_raw(Box::new(e)),
3607                 },
3608                 result_ok: false,
3609         }
3610 }
3611 #[no_mangle]
3612 pub extern "C" fn CResult_TxCreationKeysSecpErrorZ_free(_res: CResult_TxCreationKeysSecpErrorZ) { }
3613 impl Drop for CResult_TxCreationKeysSecpErrorZ {
3614         fn drop(&mut self) {
3615                 if self.result_ok {
3616                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
3617                                 let _ = unsafe { Box::from_raw(self.contents.result) };
3618                         }
3619                 } else {
3620                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
3621                                 let _ = unsafe { Box::from_raw(self.contents.err) };
3622                         }
3623                 }
3624         }
3625 }
3626 impl From<crate::c_types::CResultTempl<crate::ln::chan_utils::TxCreationKeys, crate::c_types::Secp256k1Error>> for CResult_TxCreationKeysSecpErrorZ {
3627         fn from(mut o: crate::c_types::CResultTempl<crate::ln::chan_utils::TxCreationKeys, crate::c_types::Secp256k1Error>) -> Self {
3628                 let contents = if o.result_ok {
3629                         let result = unsafe { o.contents.result };
3630                         unsafe { o.contents.result = std::ptr::null_mut() };
3631                         CResult_TxCreationKeysSecpErrorZPtr { result }
3632                 } else {
3633                         let err = unsafe { o.contents.err };
3634                         unsafe { o.contents.err = std::ptr::null_mut(); }
3635                         CResult_TxCreationKeysSecpErrorZPtr { err }
3636                 };
3637                 Self {
3638                         contents,
3639                         result_ok: o.result_ok,
3640                 }
3641         }
3642 }
3643 #[repr(C)]
3644 pub union CResult_TrustedCommitmentTransactionNoneZPtr {
3645         pub result: *mut crate::ln::chan_utils::TrustedCommitmentTransaction,
3646         /// Note that this value is always NULL, as there are no contents in the Err variant
3647         pub err: *mut std::ffi::c_void,
3648 }
3649 #[repr(C)]
3650 pub struct CResult_TrustedCommitmentTransactionNoneZ {
3651         pub contents: CResult_TrustedCommitmentTransactionNoneZPtr,
3652         pub result_ok: bool,
3653 }
3654 #[no_mangle]
3655 pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_ok(o: crate::ln::chan_utils::TrustedCommitmentTransaction) -> CResult_TrustedCommitmentTransactionNoneZ {
3656         CResult_TrustedCommitmentTransactionNoneZ {
3657                 contents: CResult_TrustedCommitmentTransactionNoneZPtr {
3658                         result: Box::into_raw(Box::new(o)),
3659                 },
3660                 result_ok: true,
3661         }
3662 }
3663 #[no_mangle]
3664 pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_err() -> CResult_TrustedCommitmentTransactionNoneZ {
3665         CResult_TrustedCommitmentTransactionNoneZ {
3666                 contents: CResult_TrustedCommitmentTransactionNoneZPtr {
3667                         err: std::ptr::null_mut(),
3668                 },
3669                 result_ok: false,
3670         }
3671 }
3672 #[no_mangle]
3673 pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_free(_res: CResult_TrustedCommitmentTransactionNoneZ) { }
3674 impl Drop for CResult_TrustedCommitmentTransactionNoneZ {
3675         fn drop(&mut self) {
3676                 if self.result_ok {
3677                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
3678                                 let _ = unsafe { Box::from_raw(self.contents.result) };
3679                         }
3680                 } else {
3681                 }
3682         }
3683 }
3684 impl From<crate::c_types::CResultTempl<crate::ln::chan_utils::TrustedCommitmentTransaction, u8>> for CResult_TrustedCommitmentTransactionNoneZ {
3685         fn from(mut o: crate::c_types::CResultTempl<crate::ln::chan_utils::TrustedCommitmentTransaction, u8>) -> Self {
3686                 let contents = if o.result_ok {
3687                         let result = unsafe { o.contents.result };
3688                         unsafe { o.contents.result = std::ptr::null_mut() };
3689                         CResult_TrustedCommitmentTransactionNoneZPtr { result }
3690                 } else {
3691                         let _ = unsafe { Box::from_raw(o.contents.err) };
3692                         o.contents.err = std::ptr::null_mut();
3693                         CResult_TrustedCommitmentTransactionNoneZPtr { err: std::ptr::null_mut() }
3694                 };
3695                 Self {
3696                         contents,
3697                         result_ok: o.result_ok,
3698                 }
3699         }
3700 }
3701 #[repr(C)]
3702 pub union CResult_CVec_SignatureZNoneZPtr {
3703         pub result: *mut crate::c_types::derived::CVec_SignatureZ,
3704         /// Note that this value is always NULL, as there are no contents in the Err variant
3705         pub err: *mut std::ffi::c_void,
3706 }
3707 #[repr(C)]
3708 pub struct CResult_CVec_SignatureZNoneZ {
3709         pub contents: CResult_CVec_SignatureZNoneZPtr,
3710         pub result_ok: bool,
3711 }
3712 #[no_mangle]
3713 pub extern "C" fn CResult_CVec_SignatureZNoneZ_ok(o: crate::c_types::derived::CVec_SignatureZ) -> CResult_CVec_SignatureZNoneZ {
3714         CResult_CVec_SignatureZNoneZ {
3715                 contents: CResult_CVec_SignatureZNoneZPtr {
3716                         result: Box::into_raw(Box::new(o)),
3717                 },
3718                 result_ok: true,
3719         }
3720 }
3721 #[no_mangle]
3722 pub extern "C" fn CResult_CVec_SignatureZNoneZ_err() -> CResult_CVec_SignatureZNoneZ {
3723         CResult_CVec_SignatureZNoneZ {
3724                 contents: CResult_CVec_SignatureZNoneZPtr {
3725                         err: std::ptr::null_mut(),
3726                 },
3727                 result_ok: false,
3728         }
3729 }
3730 #[no_mangle]
3731 pub extern "C" fn CResult_CVec_SignatureZNoneZ_free(_res: CResult_CVec_SignatureZNoneZ) { }
3732 impl Drop for CResult_CVec_SignatureZNoneZ {
3733         fn drop(&mut self) {
3734                 if self.result_ok {
3735                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
3736                                 let _ = unsafe { Box::from_raw(self.contents.result) };
3737                         }
3738                 } else {
3739                 }
3740         }
3741 }
3742 impl From<crate::c_types::CResultTempl<crate::c_types::derived::CVec_SignatureZ, u8>> for CResult_CVec_SignatureZNoneZ {
3743         fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::CVec_SignatureZ, u8>) -> Self {
3744                 let contents = if o.result_ok {
3745                         let result = unsafe { o.contents.result };
3746                         unsafe { o.contents.result = std::ptr::null_mut() };
3747                         CResult_CVec_SignatureZNoneZPtr { result }
3748                 } else {
3749                         let _ = unsafe { Box::from_raw(o.contents.err) };
3750                         o.contents.err = std::ptr::null_mut();
3751                         CResult_CVec_SignatureZNoneZPtr { err: std::ptr::null_mut() }
3752                 };
3753                 Self {
3754                         contents,
3755                         result_ok: o.result_ok,
3756                 }
3757         }
3758 }
3759 impl Clone for CResult_CVec_SignatureZNoneZ {
3760         fn clone(&self) -> Self {
3761                 if self.result_ok {
3762                         Self { result_ok: true, contents: CResult_CVec_SignatureZNoneZPtr {
3763                                 result: Box::into_raw(Box::new(<crate::c_types::derived::CVec_SignatureZ>::clone(unsafe { &*self.contents.result })))
3764                         } }
3765                 } else {
3766                         Self { result_ok: false, contents: CResult_CVec_SignatureZNoneZPtr {
3767                                 err: std::ptr::null_mut()
3768                         } }
3769                 }
3770         }
3771 }
3772 #[no_mangle]
3773 pub extern "C" fn CResult_CVec_SignatureZNoneZ_clone(orig: &CResult_CVec_SignatureZNoneZ) -> CResult_CVec_SignatureZNoneZ { orig.clone() }
3774 #[repr(C)]
3775 pub struct CVec_RouteHopZ {
3776         pub data: *mut crate::routing::router::RouteHop,
3777         pub datalen: usize
3778 }
3779 impl CVec_RouteHopZ {
3780         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::routing::router::RouteHop> {
3781                 if self.datalen == 0 { return Vec::new(); }
3782                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
3783                 self.data = std::ptr::null_mut();
3784                 self.datalen = 0;
3785                 ret
3786         }
3787         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::routing::router::RouteHop] {
3788                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
3789         }
3790 }
3791 impl From<Vec<crate::routing::router::RouteHop>> for CVec_RouteHopZ {
3792         fn from(v: Vec<crate::routing::router::RouteHop>) -> Self {
3793                 let datalen = v.len();
3794                 let data = Box::into_raw(v.into_boxed_slice());
3795                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
3796         }
3797 }
3798 #[no_mangle]
3799 pub extern "C" fn CVec_RouteHopZ_free(_res: CVec_RouteHopZ) { }
3800 impl Drop for CVec_RouteHopZ {
3801         fn drop(&mut self) {
3802                 if self.datalen == 0 { return; }
3803                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
3804         }
3805 }
3806 impl Clone for CVec_RouteHopZ {
3807         fn clone(&self) -> Self {
3808                 let mut res = Vec::new();
3809                 if self.datalen == 0 { return Self::from(res); }
3810                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
3811                 Self::from(res)
3812         }
3813 }
3814 #[repr(C)]
3815 pub struct CVec_CVec_RouteHopZZ {
3816         pub data: *mut crate::c_types::derived::CVec_RouteHopZ,
3817         pub datalen: usize
3818 }
3819 impl CVec_CVec_RouteHopZZ {
3820         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::CVec_RouteHopZ> {
3821                 if self.datalen == 0 { return Vec::new(); }
3822                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
3823                 self.data = std::ptr::null_mut();
3824                 self.datalen = 0;
3825                 ret
3826         }
3827         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CVec_RouteHopZ] {
3828                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
3829         }
3830 }
3831 impl From<Vec<crate::c_types::derived::CVec_RouteHopZ>> for CVec_CVec_RouteHopZZ {
3832         fn from(v: Vec<crate::c_types::derived::CVec_RouteHopZ>) -> Self {
3833                 let datalen = v.len();
3834                 let data = Box::into_raw(v.into_boxed_slice());
3835                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
3836         }
3837 }
3838 #[no_mangle]
3839 pub extern "C" fn CVec_CVec_RouteHopZZ_free(_res: CVec_CVec_RouteHopZZ) { }
3840 impl Drop for CVec_CVec_RouteHopZZ {
3841         fn drop(&mut self) {
3842                 if self.datalen == 0 { return; }
3843                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
3844         }
3845 }
3846 impl Clone for CVec_CVec_RouteHopZZ {
3847         fn clone(&self) -> Self {
3848                 let mut res = Vec::new();
3849                 if self.datalen == 0 { return Self::from(res); }
3850                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
3851                 Self::from(res)
3852         }
3853 }
3854 #[repr(C)]
3855 pub union CResult_RouteDecodeErrorZPtr {
3856         pub result: *mut crate::routing::router::Route,
3857         pub err: *mut crate::ln::msgs::DecodeError,
3858 }
3859 #[repr(C)]
3860 pub struct CResult_RouteDecodeErrorZ {
3861         pub contents: CResult_RouteDecodeErrorZPtr,
3862         pub result_ok: bool,
3863 }
3864 #[no_mangle]
3865 pub extern "C" fn CResult_RouteDecodeErrorZ_ok(o: crate::routing::router::Route) -> CResult_RouteDecodeErrorZ {
3866         CResult_RouteDecodeErrorZ {
3867                 contents: CResult_RouteDecodeErrorZPtr {
3868                         result: Box::into_raw(Box::new(o)),
3869                 },
3870                 result_ok: true,
3871         }
3872 }
3873 #[no_mangle]
3874 pub extern "C" fn CResult_RouteDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_RouteDecodeErrorZ {
3875         CResult_RouteDecodeErrorZ {
3876                 contents: CResult_RouteDecodeErrorZPtr {
3877                         err: Box::into_raw(Box::new(e)),
3878                 },
3879                 result_ok: false,
3880         }
3881 }
3882 #[no_mangle]
3883 pub extern "C" fn CResult_RouteDecodeErrorZ_free(_res: CResult_RouteDecodeErrorZ) { }
3884 impl Drop for CResult_RouteDecodeErrorZ {
3885         fn drop(&mut self) {
3886                 if self.result_ok {
3887                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
3888                                 let _ = unsafe { Box::from_raw(self.contents.result) };
3889                         }
3890                 } else {
3891                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
3892                                 let _ = unsafe { Box::from_raw(self.contents.err) };
3893                         }
3894                 }
3895         }
3896 }
3897 impl From<crate::c_types::CResultTempl<crate::routing::router::Route, crate::ln::msgs::DecodeError>> for CResult_RouteDecodeErrorZ {
3898         fn from(mut o: crate::c_types::CResultTempl<crate::routing::router::Route, crate::ln::msgs::DecodeError>) -> Self {
3899                 let contents = if o.result_ok {
3900                         let result = unsafe { o.contents.result };
3901                         unsafe { o.contents.result = std::ptr::null_mut() };
3902                         CResult_RouteDecodeErrorZPtr { result }
3903                 } else {
3904                         let err = unsafe { o.contents.err };
3905                         unsafe { o.contents.err = std::ptr::null_mut(); }
3906                         CResult_RouteDecodeErrorZPtr { err }
3907                 };
3908                 Self {
3909                         contents,
3910                         result_ok: o.result_ok,
3911                 }
3912         }
3913 }
3914 impl Clone for CResult_RouteDecodeErrorZ {
3915         fn clone(&self) -> Self {
3916                 if self.result_ok {
3917                         Self { result_ok: true, contents: CResult_RouteDecodeErrorZPtr {
3918                                 result: Box::into_raw(Box::new(<crate::routing::router::Route>::clone(unsafe { &*self.contents.result })))
3919                         } }
3920                 } else {
3921                         Self { result_ok: false, contents: CResult_RouteDecodeErrorZPtr {
3922                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
3923                         } }
3924                 }
3925         }
3926 }
3927 #[no_mangle]
3928 pub extern "C" fn CResult_RouteDecodeErrorZ_clone(orig: &CResult_RouteDecodeErrorZ) -> CResult_RouteDecodeErrorZ { orig.clone() }
3929 #[repr(C)]
3930 pub struct CVec_RouteHintZ {
3931         pub data: *mut crate::routing::router::RouteHint,
3932         pub datalen: usize
3933 }
3934 impl CVec_RouteHintZ {
3935         #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::routing::router::RouteHint> {
3936                 if self.datalen == 0 { return Vec::new(); }
3937                 let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
3938                 self.data = std::ptr::null_mut();
3939                 self.datalen = 0;
3940                 ret
3941         }
3942         #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::routing::router::RouteHint] {
3943                 unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
3944         }
3945 }
3946 impl From<Vec<crate::routing::router::RouteHint>> for CVec_RouteHintZ {
3947         fn from(v: Vec<crate::routing::router::RouteHint>) -> Self {
3948                 let datalen = v.len();
3949                 let data = Box::into_raw(v.into_boxed_slice());
3950                 Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
3951         }
3952 }
3953 #[no_mangle]
3954 pub extern "C" fn CVec_RouteHintZ_free(_res: CVec_RouteHintZ) { }
3955 impl Drop for CVec_RouteHintZ {
3956         fn drop(&mut self) {
3957                 if self.datalen == 0 { return; }
3958                 unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
3959         }
3960 }
3961 impl Clone for CVec_RouteHintZ {
3962         fn clone(&self) -> Self {
3963                 let mut res = Vec::new();
3964                 if self.datalen == 0 { return Self::from(res); }
3965                 res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
3966                 Self::from(res)
3967         }
3968 }
3969 #[repr(C)]
3970 pub union CResult_RouteLightningErrorZPtr {
3971         pub result: *mut crate::routing::router::Route,
3972         pub err: *mut crate::ln::msgs::LightningError,
3973 }
3974 #[repr(C)]
3975 pub struct CResult_RouteLightningErrorZ {
3976         pub contents: CResult_RouteLightningErrorZPtr,
3977         pub result_ok: bool,
3978 }
3979 #[no_mangle]
3980 pub extern "C" fn CResult_RouteLightningErrorZ_ok(o: crate::routing::router::Route) -> CResult_RouteLightningErrorZ {
3981         CResult_RouteLightningErrorZ {
3982                 contents: CResult_RouteLightningErrorZPtr {
3983                         result: Box::into_raw(Box::new(o)),
3984                 },
3985                 result_ok: true,
3986         }
3987 }
3988 #[no_mangle]
3989 pub extern "C" fn CResult_RouteLightningErrorZ_err(e: crate::ln::msgs::LightningError) -> CResult_RouteLightningErrorZ {
3990         CResult_RouteLightningErrorZ {
3991                 contents: CResult_RouteLightningErrorZPtr {
3992                         err: Box::into_raw(Box::new(e)),
3993                 },
3994                 result_ok: false,
3995         }
3996 }
3997 #[no_mangle]
3998 pub extern "C" fn CResult_RouteLightningErrorZ_free(_res: CResult_RouteLightningErrorZ) { }
3999 impl Drop for CResult_RouteLightningErrorZ {
4000         fn drop(&mut self) {
4001                 if self.result_ok {
4002                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
4003                                 let _ = unsafe { Box::from_raw(self.contents.result) };
4004                         }
4005                 } else {
4006                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
4007                                 let _ = unsafe { Box::from_raw(self.contents.err) };
4008                         }
4009                 }
4010         }
4011 }
4012 impl From<crate::c_types::CResultTempl<crate::routing::router::Route, crate::ln::msgs::LightningError>> for CResult_RouteLightningErrorZ {
4013         fn from(mut o: crate::c_types::CResultTempl<crate::routing::router::Route, crate::ln::msgs::LightningError>) -> Self {
4014                 let contents = if o.result_ok {
4015                         let result = unsafe { o.contents.result };
4016                         unsafe { o.contents.result = std::ptr::null_mut() };
4017                         CResult_RouteLightningErrorZPtr { result }
4018                 } else {
4019                         let err = unsafe { o.contents.err };
4020                         unsafe { o.contents.err = std::ptr::null_mut(); }
4021                         CResult_RouteLightningErrorZPtr { err }
4022                 };
4023                 Self {
4024                         contents,
4025                         result_ok: o.result_ok,
4026                 }
4027         }
4028 }
4029 impl Clone for CResult_RouteLightningErrorZ {
4030         fn clone(&self) -> Self {
4031                 if self.result_ok {
4032                         Self { result_ok: true, contents: CResult_RouteLightningErrorZPtr {
4033                                 result: Box::into_raw(Box::new(<crate::routing::router::Route>::clone(unsafe { &*self.contents.result })))
4034                         } }
4035                 } else {
4036                         Self { result_ok: false, contents: CResult_RouteLightningErrorZPtr {
4037                                 err: Box::into_raw(Box::new(<crate::ln::msgs::LightningError>::clone(unsafe { &*self.contents.err })))
4038                         } }
4039                 }
4040         }
4041 }
4042 #[no_mangle]
4043 pub extern "C" fn CResult_RouteLightningErrorZ_clone(orig: &CResult_RouteLightningErrorZ) -> CResult_RouteLightningErrorZ { orig.clone() }
4044 #[repr(C)]
4045 pub union CResult_RoutingFeesDecodeErrorZPtr {
4046         pub result: *mut crate::routing::network_graph::RoutingFees,
4047         pub err: *mut crate::ln::msgs::DecodeError,
4048 }
4049 #[repr(C)]
4050 pub struct CResult_RoutingFeesDecodeErrorZ {
4051         pub contents: CResult_RoutingFeesDecodeErrorZPtr,
4052         pub result_ok: bool,
4053 }
4054 #[no_mangle]
4055 pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_ok(o: crate::routing::network_graph::RoutingFees) -> CResult_RoutingFeesDecodeErrorZ {
4056         CResult_RoutingFeesDecodeErrorZ {
4057                 contents: CResult_RoutingFeesDecodeErrorZPtr {
4058                         result: Box::into_raw(Box::new(o)),
4059                 },
4060                 result_ok: true,
4061         }
4062 }
4063 #[no_mangle]
4064 pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_RoutingFeesDecodeErrorZ {
4065         CResult_RoutingFeesDecodeErrorZ {
4066                 contents: CResult_RoutingFeesDecodeErrorZPtr {
4067                         err: Box::into_raw(Box::new(e)),
4068                 },
4069                 result_ok: false,
4070         }
4071 }
4072 #[no_mangle]
4073 pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_free(_res: CResult_RoutingFeesDecodeErrorZ) { }
4074 impl Drop for CResult_RoutingFeesDecodeErrorZ {
4075         fn drop(&mut self) {
4076                 if self.result_ok {
4077                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
4078                                 let _ = unsafe { Box::from_raw(self.contents.result) };
4079                         }
4080                 } else {
4081                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
4082                                 let _ = unsafe { Box::from_raw(self.contents.err) };
4083                         }
4084                 }
4085         }
4086 }
4087 impl From<crate::c_types::CResultTempl<crate::routing::network_graph::RoutingFees, crate::ln::msgs::DecodeError>> for CResult_RoutingFeesDecodeErrorZ {
4088         fn from(mut o: crate::c_types::CResultTempl<crate::routing::network_graph::RoutingFees, crate::ln::msgs::DecodeError>) -> Self {
4089                 let contents = if o.result_ok {
4090                         let result = unsafe { o.contents.result };
4091                         unsafe { o.contents.result = std::ptr::null_mut() };
4092                         CResult_RoutingFeesDecodeErrorZPtr { result }
4093                 } else {
4094                         let err = unsafe { o.contents.err };
4095                         unsafe { o.contents.err = std::ptr::null_mut(); }
4096                         CResult_RoutingFeesDecodeErrorZPtr { err }
4097                 };
4098                 Self {
4099                         contents,
4100                         result_ok: o.result_ok,
4101                 }
4102         }
4103 }
4104 impl Clone for CResult_RoutingFeesDecodeErrorZ {
4105         fn clone(&self) -> Self {
4106                 if self.result_ok {
4107                         Self { result_ok: true, contents: CResult_RoutingFeesDecodeErrorZPtr {
4108                                 result: Box::into_raw(Box::new(<crate::routing::network_graph::RoutingFees>::clone(unsafe { &*self.contents.result })))
4109                         } }
4110                 } else {
4111                         Self { result_ok: false, contents: CResult_RoutingFeesDecodeErrorZPtr {
4112                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
4113                         } }
4114                 }
4115         }
4116 }
4117 #[no_mangle]
4118 pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_clone(orig: &CResult_RoutingFeesDecodeErrorZ) -> CResult_RoutingFeesDecodeErrorZ { orig.clone() }
4119 #[repr(C)]
4120 pub union CResult_NodeAnnouncementInfoDecodeErrorZPtr {
4121         pub result: *mut crate::routing::network_graph::NodeAnnouncementInfo,
4122         pub err: *mut crate::ln::msgs::DecodeError,
4123 }
4124 #[repr(C)]
4125 pub struct CResult_NodeAnnouncementInfoDecodeErrorZ {
4126         pub contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr,
4127         pub result_ok: bool,
4128 }
4129 #[no_mangle]
4130 pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o: crate::routing::network_graph::NodeAnnouncementInfo) -> CResult_NodeAnnouncementInfoDecodeErrorZ {
4131         CResult_NodeAnnouncementInfoDecodeErrorZ {
4132                 contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr {
4133                         result: Box::into_raw(Box::new(o)),
4134                 },
4135                 result_ok: true,
4136         }
4137 }
4138 #[no_mangle]
4139 pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_NodeAnnouncementInfoDecodeErrorZ {
4140         CResult_NodeAnnouncementInfoDecodeErrorZ {
4141                 contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr {
4142                         err: Box::into_raw(Box::new(e)),
4143                 },
4144                 result_ok: false,
4145         }
4146 }
4147 #[no_mangle]
4148 pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res: CResult_NodeAnnouncementInfoDecodeErrorZ) { }
4149 impl Drop for CResult_NodeAnnouncementInfoDecodeErrorZ {
4150         fn drop(&mut self) {
4151                 if self.result_ok {
4152                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
4153                                 let _ = unsafe { Box::from_raw(self.contents.result) };
4154                         }
4155                 } else {
4156                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
4157                                 let _ = unsafe { Box::from_raw(self.contents.err) };
4158                         }
4159                 }
4160         }
4161 }
4162 impl From<crate::c_types::CResultTempl<crate::routing::network_graph::NodeAnnouncementInfo, crate::ln::msgs::DecodeError>> for CResult_NodeAnnouncementInfoDecodeErrorZ {
4163         fn from(mut o: crate::c_types::CResultTempl<crate::routing::network_graph::NodeAnnouncementInfo, crate::ln::msgs::DecodeError>) -> Self {
4164                 let contents = if o.result_ok {
4165                         let result = unsafe { o.contents.result };
4166                         unsafe { o.contents.result = std::ptr::null_mut() };
4167                         CResult_NodeAnnouncementInfoDecodeErrorZPtr { result }
4168                 } else {
4169                         let err = unsafe { o.contents.err };
4170                         unsafe { o.contents.err = std::ptr::null_mut(); }
4171                         CResult_NodeAnnouncementInfoDecodeErrorZPtr { err }
4172                 };
4173                 Self {
4174                         contents,
4175                         result_ok: o.result_ok,
4176                 }
4177         }
4178 }
4179 impl Clone for CResult_NodeAnnouncementInfoDecodeErrorZ {
4180         fn clone(&self) -> Self {
4181                 if self.result_ok {
4182                         Self { result_ok: true, contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr {
4183                                 result: Box::into_raw(Box::new(<crate::routing::network_graph::NodeAnnouncementInfo>::clone(unsafe { &*self.contents.result })))
4184                         } }
4185                 } else {
4186                         Self { result_ok: false, contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr {
4187                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
4188                         } }
4189                 }
4190         }
4191 }
4192 #[no_mangle]
4193 pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementInfoDecodeErrorZ) -> CResult_NodeAnnouncementInfoDecodeErrorZ { orig.clone() }
4194 #[repr(C)]
4195 pub union CResult_NodeInfoDecodeErrorZPtr {
4196         pub result: *mut crate::routing::network_graph::NodeInfo,
4197         pub err: *mut crate::ln::msgs::DecodeError,
4198 }
4199 #[repr(C)]
4200 pub struct CResult_NodeInfoDecodeErrorZ {
4201         pub contents: CResult_NodeInfoDecodeErrorZPtr,
4202         pub result_ok: bool,
4203 }
4204 #[no_mangle]
4205 pub extern "C" fn CResult_NodeInfoDecodeErrorZ_ok(o: crate::routing::network_graph::NodeInfo) -> CResult_NodeInfoDecodeErrorZ {
4206         CResult_NodeInfoDecodeErrorZ {
4207                 contents: CResult_NodeInfoDecodeErrorZPtr {
4208                         result: Box::into_raw(Box::new(o)),
4209                 },
4210                 result_ok: true,
4211         }
4212 }
4213 #[no_mangle]
4214 pub extern "C" fn CResult_NodeInfoDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_NodeInfoDecodeErrorZ {
4215         CResult_NodeInfoDecodeErrorZ {
4216                 contents: CResult_NodeInfoDecodeErrorZPtr {
4217                         err: Box::into_raw(Box::new(e)),
4218                 },
4219                 result_ok: false,
4220         }
4221 }
4222 #[no_mangle]
4223 pub extern "C" fn CResult_NodeInfoDecodeErrorZ_free(_res: CResult_NodeInfoDecodeErrorZ) { }
4224 impl Drop for CResult_NodeInfoDecodeErrorZ {
4225         fn drop(&mut self) {
4226                 if self.result_ok {
4227                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
4228                                 let _ = unsafe { Box::from_raw(self.contents.result) };
4229                         }
4230                 } else {
4231                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
4232                                 let _ = unsafe { Box::from_raw(self.contents.err) };
4233                         }
4234                 }
4235         }
4236 }
4237 impl From<crate::c_types::CResultTempl<crate::routing::network_graph::NodeInfo, crate::ln::msgs::DecodeError>> for CResult_NodeInfoDecodeErrorZ {
4238         fn from(mut o: crate::c_types::CResultTempl<crate::routing::network_graph::NodeInfo, crate::ln::msgs::DecodeError>) -> Self {
4239                 let contents = if o.result_ok {
4240                         let result = unsafe { o.contents.result };
4241                         unsafe { o.contents.result = std::ptr::null_mut() };
4242                         CResult_NodeInfoDecodeErrorZPtr { result }
4243                 } else {
4244                         let err = unsafe { o.contents.err };
4245                         unsafe { o.contents.err = std::ptr::null_mut(); }
4246                         CResult_NodeInfoDecodeErrorZPtr { err }
4247                 };
4248                 Self {
4249                         contents,
4250                         result_ok: o.result_ok,
4251                 }
4252         }
4253 }
4254 impl Clone for CResult_NodeInfoDecodeErrorZ {
4255         fn clone(&self) -> Self {
4256                 if self.result_ok {
4257                         Self { result_ok: true, contents: CResult_NodeInfoDecodeErrorZPtr {
4258                                 result: Box::into_raw(Box::new(<crate::routing::network_graph::NodeInfo>::clone(unsafe { &*self.contents.result })))
4259                         } }
4260                 } else {
4261                         Self { result_ok: false, contents: CResult_NodeInfoDecodeErrorZPtr {
4262                                 err: Box::into_raw(Box::new(<crate::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
4263                         } }
4264                 }
4265         }
4266 }
4267 #[no_mangle]
4268 pub extern "C" fn CResult_NodeInfoDecodeErrorZ_clone(orig: &CResult_NodeInfoDecodeErrorZ) -> CResult_NodeInfoDecodeErrorZ { orig.clone() }
4269 #[repr(C)]
4270 pub union CResult_NetworkGraphDecodeErrorZPtr {
4271         pub result: *mut crate::routing::network_graph::NetworkGraph,
4272         pub err: *mut crate::ln::msgs::DecodeError,
4273 }
4274 #[repr(C)]
4275 pub struct CResult_NetworkGraphDecodeErrorZ {
4276         pub contents: CResult_NetworkGraphDecodeErrorZPtr,
4277         pub result_ok: bool,
4278 }
4279 #[no_mangle]
4280 pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_ok(o: crate::routing::network_graph::NetworkGraph) -> CResult_NetworkGraphDecodeErrorZ {
4281         CResult_NetworkGraphDecodeErrorZ {
4282                 contents: CResult_NetworkGraphDecodeErrorZPtr {
4283                         result: Box::into_raw(Box::new(o)),
4284                 },
4285                 result_ok: true,
4286         }
4287 }
4288 #[no_mangle]
4289 pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_NetworkGraphDecodeErrorZ {
4290         CResult_NetworkGraphDecodeErrorZ {
4291                 contents: CResult_NetworkGraphDecodeErrorZPtr {
4292                         err: Box::into_raw(Box::new(e)),
4293                 },
4294                 result_ok: false,
4295         }
4296 }
4297 #[no_mangle]
4298 pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_free(_res: CResult_NetworkGraphDecodeErrorZ) { }
4299 impl Drop for CResult_NetworkGraphDecodeErrorZ {
4300         fn drop(&mut self) {
4301                 if self.result_ok {
4302                         if unsafe { !(self.contents.result as *mut ()).is_null() } {
4303                                 let _ = unsafe { Box::from_raw(self.contents.result) };
4304                         }
4305                 } else {
4306                         if unsafe { !(self.contents.err as *mut ()).is_null() } {
4307                                 let _ = unsafe { Box::from_raw(self.contents.err) };
4308                         }
4309                 }
4310         }
4311 }
4312 impl From<crate::c_types::CResultTempl<crate::routing::network_graph::NetworkGraph, crate::ln::msgs::DecodeError>> for CResult_NetworkGraphDecodeErrorZ {
4313         fn from(mut o: crate::c_types::CResultTempl<crate::routing::network_graph::NetworkGraph, crate::ln::msgs::DecodeError>) -> Self {
4314                 let contents = if o.result_ok {
4315                         let result = unsafe { o.contents.result };
4316                         unsafe { o.contents.result = std::ptr::null_mut() };
4317                         CResult_NetworkGraphDecodeErrorZPtr { result }
4318                 } else {
4319                         let err = unsafe { o.contents.err };
4320                         unsafe { o.contents.err = std::ptr::null_mut(); }
4321                         CResult_NetworkGraphDecodeErrorZPtr { err }
4322                 };
4323                 Self {
4324                         contents,
4325                         result_ok: o.result_ok,
4326                 }
4327         }
4328 }