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