Merge pull request #40 from TheBlueMatt/main
[ldk-c-bindings] / lightning-c-bindings / src / lightning / ln / features.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
8
9 //! Feature flag definitions for the Lightning protocol according to [BOLT #9].
10 //!
11 //! Lightning nodes advertise a supported set of operation through feature flags. Features are
12 //! applicable for a specific context as indicated in some [messages]. [`Features`] encapsulates
13 //! behavior for specifying and checking feature flags for a particular context. Each feature is
14 //! defined internally by a trait specifying the corresponding flags (i.e., even and odd bits).
15 //!
16 //! Whether a feature is considered \"known\" or \"unknown\" is relative to the implementation, whereas
17 //! the term \"supports\" is used in reference to a particular set of [`Features`]. That is, a node
18 //! supports a feature if it advertises the feature (as either required or optional) to its peers.
19 //! And the implementation can interpret a feature if the feature is known to it.
20 //!
21 //! [BOLT #9]: https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md
22 //! [messages]: crate::ln::msgs
23
24 use std::str::FromStr;
25 use std::ffi::c_void;
26 use bitcoin::hashes::Hash;
27 use crate::c_types::*;
28
29 mod sealed {
30
31 use std::str::FromStr;
32 use std::ffi::c_void;
33 use bitcoin::hashes::Hash;
34 use crate::c_types::*;
35
36 }
37 /// Checks if two InitFeaturess contain equal inner contents.
38 /// This ignores pointers and is_owned flags and looks at the values in fields.
39 /// Two objects with NULL inner values will be considered "equal" here.
40 #[no_mangle]
41 pub extern "C" fn InitFeatures_eq(a: &InitFeatures, b: &InitFeatures) -> bool {
42         if a.inner == b.inner { return true; }
43         if a.inner.is_null() || b.inner.is_null() { return false; }
44         if a.get_native_ref() == b.get_native_ref() { true } else { false }
45 }
46 /// Checks if two NodeFeaturess contain equal inner contents.
47 /// This ignores pointers and is_owned flags and looks at the values in fields.
48 /// Two objects with NULL inner values will be considered "equal" here.
49 #[no_mangle]
50 pub extern "C" fn NodeFeatures_eq(a: &NodeFeatures, b: &NodeFeatures) -> bool {
51         if a.inner == b.inner { return true; }
52         if a.inner.is_null() || b.inner.is_null() { return false; }
53         if a.get_native_ref() == b.get_native_ref() { true } else { false }
54 }
55 /// Checks if two ChannelFeaturess contain equal inner contents.
56 /// This ignores pointers and is_owned flags and looks at the values in fields.
57 /// Two objects with NULL inner values will be considered "equal" here.
58 #[no_mangle]
59 pub extern "C" fn ChannelFeatures_eq(a: &ChannelFeatures, b: &ChannelFeatures) -> bool {
60         if a.inner == b.inner { return true; }
61         if a.inner.is_null() || b.inner.is_null() { return false; }
62         if a.get_native_ref() == b.get_native_ref() { true } else { false }
63 }
64 /// Checks if two InvoiceFeaturess contain equal inner contents.
65 /// This ignores pointers and is_owned flags and looks at the values in fields.
66 /// Two objects with NULL inner values will be considered "equal" here.
67 #[no_mangle]
68 pub extern "C" fn InvoiceFeatures_eq(a: &InvoiceFeatures, b: &InvoiceFeatures) -> bool {
69         if a.inner == b.inner { return true; }
70         if a.inner.is_null() || b.inner.is_null() { return false; }
71         if a.get_native_ref() == b.get_native_ref() { true } else { false }
72 }
73 impl Clone for InitFeatures {
74         fn clone(&self) -> Self {
75                 Self {
76                         inner: if <*mut nativeInitFeatures>::is_null(self.inner) { std::ptr::null_mut() } else {
77                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
78                         is_owned: true,
79                 }
80         }
81 }
82 #[allow(unused)]
83 /// Used only if an object of this type is returned as a trait impl by a method
84 pub(crate) extern "C" fn InitFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
85         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInitFeatures)).clone() })) as *mut c_void
86 }
87 #[no_mangle]
88 /// Creates a copy of the InitFeatures
89 pub extern "C" fn InitFeatures_clone(orig: &InitFeatures) -> InitFeatures {
90         orig.clone()
91 }
92 impl Clone for NodeFeatures {
93         fn clone(&self) -> Self {
94                 Self {
95                         inner: if <*mut nativeNodeFeatures>::is_null(self.inner) { std::ptr::null_mut() } else {
96                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
97                         is_owned: true,
98                 }
99         }
100 }
101 #[allow(unused)]
102 /// Used only if an object of this type is returned as a trait impl by a method
103 pub(crate) extern "C" fn NodeFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
104         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeFeatures)).clone() })) as *mut c_void
105 }
106 #[no_mangle]
107 /// Creates a copy of the NodeFeatures
108 pub extern "C" fn NodeFeatures_clone(orig: &NodeFeatures) -> NodeFeatures {
109         orig.clone()
110 }
111 impl Clone for ChannelFeatures {
112         fn clone(&self) -> Self {
113                 Self {
114                         inner: if <*mut nativeChannelFeatures>::is_null(self.inner) { std::ptr::null_mut() } else {
115                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
116                         is_owned: true,
117                 }
118         }
119 }
120 #[allow(unused)]
121 /// Used only if an object of this type is returned as a trait impl by a method
122 pub(crate) extern "C" fn ChannelFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
123         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelFeatures)).clone() })) as *mut c_void
124 }
125 #[no_mangle]
126 /// Creates a copy of the ChannelFeatures
127 pub extern "C" fn ChannelFeatures_clone(orig: &ChannelFeatures) -> ChannelFeatures {
128         orig.clone()
129 }
130 impl Clone for InvoiceFeatures {
131         fn clone(&self) -> Self {
132                 Self {
133                         inner: if <*mut nativeInvoiceFeatures>::is_null(self.inner) { std::ptr::null_mut() } else {
134                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
135                         is_owned: true,
136                 }
137         }
138 }
139 #[allow(unused)]
140 /// Used only if an object of this type is returned as a trait impl by a method
141 pub(crate) extern "C" fn InvoiceFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
142         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoiceFeatures)).clone() })) as *mut c_void
143 }
144 #[no_mangle]
145 /// Creates a copy of the InvoiceFeatures
146 pub extern "C" fn InvoiceFeatures_clone(orig: &InvoiceFeatures) -> InvoiceFeatures {
147         orig.clone()
148 }
149
150 use lightning::ln::features::InitFeatures as nativeInitFeaturesImport;
151 type nativeInitFeatures = nativeInitFeaturesImport;
152
153 /// Features used within an `init` message.
154 #[must_use]
155 #[repr(C)]
156 pub struct InitFeatures {
157         /// A pointer to the opaque Rust object.
158
159         /// Nearly everywhere, inner must be non-null, however in places where
160         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
161         pub inner: *mut nativeInitFeatures,
162         /// Indicates that this is the only struct which contains the same pointer.
163
164         /// Rust functions which take ownership of an object provided via an argument require
165         /// this to be true and invalidate the object pointed to by inner.
166         pub is_owned: bool,
167 }
168
169 impl Drop for InitFeatures {
170         fn drop(&mut self) {
171                 if self.is_owned && !<*mut nativeInitFeatures>::is_null(self.inner) {
172                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
173                 }
174         }
175 }
176 /// Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL.
177 #[no_mangle]
178 pub extern "C" fn InitFeatures_free(this_obj: InitFeatures) { }
179 #[allow(unused)]
180 /// Used only if an object of this type is returned as a trait impl by a method
181 extern "C" fn InitFeatures_free_void(this_ptr: *mut c_void) {
182         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInitFeatures); }
183 }
184 #[allow(unused)]
185 impl InitFeatures {
186         pub(crate) fn get_native_ref(&self) -> &'static nativeInitFeatures {
187                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
188         }
189         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInitFeatures {
190                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
191         }
192         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
193         pub(crate) fn take_inner(mut self) -> *mut nativeInitFeatures {
194                 assert!(self.is_owned);
195                 let ret = ObjOps::untweak_ptr(self.inner);
196                 self.inner = std::ptr::null_mut();
197                 ret
198         }
199 }
200
201 use lightning::ln::features::NodeFeatures as nativeNodeFeaturesImport;
202 type nativeNodeFeatures = nativeNodeFeaturesImport;
203
204 /// Features used within a `node_announcement` message.
205 #[must_use]
206 #[repr(C)]
207 pub struct NodeFeatures {
208         /// A pointer to the opaque Rust object.
209
210         /// Nearly everywhere, inner must be non-null, however in places where
211         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
212         pub inner: *mut nativeNodeFeatures,
213         /// Indicates that this is the only struct which contains the same pointer.
214
215         /// Rust functions which take ownership of an object provided via an argument require
216         /// this to be true and invalidate the object pointed to by inner.
217         pub is_owned: bool,
218 }
219
220 impl Drop for NodeFeatures {
221         fn drop(&mut self) {
222                 if self.is_owned && !<*mut nativeNodeFeatures>::is_null(self.inner) {
223                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
224                 }
225         }
226 }
227 /// Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL.
228 #[no_mangle]
229 pub extern "C" fn NodeFeatures_free(this_obj: NodeFeatures) { }
230 #[allow(unused)]
231 /// Used only if an object of this type is returned as a trait impl by a method
232 extern "C" fn NodeFeatures_free_void(this_ptr: *mut c_void) {
233         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeFeatures); }
234 }
235 #[allow(unused)]
236 impl NodeFeatures {
237         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeFeatures {
238                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
239         }
240         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeFeatures {
241                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
242         }
243         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
244         pub(crate) fn take_inner(mut self) -> *mut nativeNodeFeatures {
245                 assert!(self.is_owned);
246                 let ret = ObjOps::untweak_ptr(self.inner);
247                 self.inner = std::ptr::null_mut();
248                 ret
249         }
250 }
251
252 use lightning::ln::features::ChannelFeatures as nativeChannelFeaturesImport;
253 type nativeChannelFeatures = nativeChannelFeaturesImport;
254
255 /// Features used within a `channel_announcement` message.
256 #[must_use]
257 #[repr(C)]
258 pub struct ChannelFeatures {
259         /// A pointer to the opaque Rust object.
260
261         /// Nearly everywhere, inner must be non-null, however in places where
262         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
263         pub inner: *mut nativeChannelFeatures,
264         /// Indicates that this is the only struct which contains the same pointer.
265
266         /// Rust functions which take ownership of an object provided via an argument require
267         /// this to be true and invalidate the object pointed to by inner.
268         pub is_owned: bool,
269 }
270
271 impl Drop for ChannelFeatures {
272         fn drop(&mut self) {
273                 if self.is_owned && !<*mut nativeChannelFeatures>::is_null(self.inner) {
274                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
275                 }
276         }
277 }
278 /// Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL.
279 #[no_mangle]
280 pub extern "C" fn ChannelFeatures_free(this_obj: ChannelFeatures) { }
281 #[allow(unused)]
282 /// Used only if an object of this type is returned as a trait impl by a method
283 extern "C" fn ChannelFeatures_free_void(this_ptr: *mut c_void) {
284         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelFeatures); }
285 }
286 #[allow(unused)]
287 impl ChannelFeatures {
288         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelFeatures {
289                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
290         }
291         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelFeatures {
292                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
293         }
294         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
295         pub(crate) fn take_inner(mut self) -> *mut nativeChannelFeatures {
296                 assert!(self.is_owned);
297                 let ret = ObjOps::untweak_ptr(self.inner);
298                 self.inner = std::ptr::null_mut();
299                 ret
300         }
301 }
302
303 use lightning::ln::features::InvoiceFeatures as nativeInvoiceFeaturesImport;
304 type nativeInvoiceFeatures = nativeInvoiceFeaturesImport;
305
306 /// Features used within an invoice.
307 #[must_use]
308 #[repr(C)]
309 pub struct InvoiceFeatures {
310         /// A pointer to the opaque Rust object.
311
312         /// Nearly everywhere, inner must be non-null, however in places where
313         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
314         pub inner: *mut nativeInvoiceFeatures,
315         /// Indicates that this is the only struct which contains the same pointer.
316
317         /// Rust functions which take ownership of an object provided via an argument require
318         /// this to be true and invalidate the object pointed to by inner.
319         pub is_owned: bool,
320 }
321
322 impl Drop for InvoiceFeatures {
323         fn drop(&mut self) {
324                 if self.is_owned && !<*mut nativeInvoiceFeatures>::is_null(self.inner) {
325                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
326                 }
327         }
328 }
329 /// Frees any resources used by the InvoiceFeatures, if is_owned is set and inner is non-NULL.
330 #[no_mangle]
331 pub extern "C" fn InvoiceFeatures_free(this_obj: InvoiceFeatures) { }
332 #[allow(unused)]
333 /// Used only if an object of this type is returned as a trait impl by a method
334 extern "C" fn InvoiceFeatures_free_void(this_ptr: *mut c_void) {
335         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInvoiceFeatures); }
336 }
337 #[allow(unused)]
338 impl InvoiceFeatures {
339         pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceFeatures {
340                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
341         }
342         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceFeatures {
343                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
344         }
345         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
346         pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceFeatures {
347                 assert!(self.is_owned);
348                 let ret = ObjOps::untweak_ptr(self.inner);
349                 self.inner = std::ptr::null_mut();
350                 ret
351         }
352 }
353 /// Create a blank Features with no features set
354 #[must_use]
355 #[no_mangle]
356 pub extern "C" fn InitFeatures_empty() -> InitFeatures {
357         let mut ret = lightning::ln::features::InitFeatures::empty();
358         InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
359 }
360
361 /// Creates a Features with the bits set which are known by the implementation
362 #[must_use]
363 #[no_mangle]
364 pub extern "C" fn InitFeatures_known() -> InitFeatures {
365         let mut ret = lightning::ln::features::InitFeatures::known();
366         InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
367 }
368
369 /// Create a blank Features with no features set
370 #[must_use]
371 #[no_mangle]
372 pub extern "C" fn NodeFeatures_empty() -> NodeFeatures {
373         let mut ret = lightning::ln::features::NodeFeatures::empty();
374         NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
375 }
376
377 /// Creates a Features with the bits set which are known by the implementation
378 #[must_use]
379 #[no_mangle]
380 pub extern "C" fn NodeFeatures_known() -> NodeFeatures {
381         let mut ret = lightning::ln::features::NodeFeatures::known();
382         NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
383 }
384
385 /// Create a blank Features with no features set
386 #[must_use]
387 #[no_mangle]
388 pub extern "C" fn ChannelFeatures_empty() -> ChannelFeatures {
389         let mut ret = lightning::ln::features::ChannelFeatures::empty();
390         ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
391 }
392
393 /// Creates a Features with the bits set which are known by the implementation
394 #[must_use]
395 #[no_mangle]
396 pub extern "C" fn ChannelFeatures_known() -> ChannelFeatures {
397         let mut ret = lightning::ln::features::ChannelFeatures::known();
398         ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
399 }
400
401 /// Create a blank Features with no features set
402 #[must_use]
403 #[no_mangle]
404 pub extern "C" fn InvoiceFeatures_empty() -> InvoiceFeatures {
405         let mut ret = lightning::ln::features::InvoiceFeatures::empty();
406         InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
407 }
408
409 /// Creates a Features with the bits set which are known by the implementation
410 #[must_use]
411 #[no_mangle]
412 pub extern "C" fn InvoiceFeatures_known() -> InvoiceFeatures {
413         let mut ret = lightning::ln::features::InvoiceFeatures::known();
414         InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
415 }
416
417 /// Returns whether the `payment_secret` feature is supported.
418 #[must_use]
419 #[no_mangle]
420 pub extern "C" fn InitFeatures_supports_payment_secret(this_arg: &InitFeatures) -> bool {
421         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret();
422         ret
423 }
424
425 /// Returns whether the `payment_secret` feature is supported.
426 #[must_use]
427 #[no_mangle]
428 pub extern "C" fn NodeFeatures_supports_payment_secret(this_arg: &NodeFeatures) -> bool {
429         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret();
430         ret
431 }
432
433 /// Returns whether the `payment_secret` feature is supported.
434 #[must_use]
435 #[no_mangle]
436 pub extern "C" fn InvoiceFeatures_supports_payment_secret(this_arg: &InvoiceFeatures) -> bool {
437         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret();
438         ret
439 }
440
441 #[no_mangle]
442 /// Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read
443 pub extern "C" fn InitFeatures_write(obj: &InitFeatures) -> crate::c_types::derived::CVec_u8Z {
444         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
445 }
446 #[no_mangle]
447 pub(crate) extern "C" fn InitFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
448         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInitFeatures) })
449 }
450 #[no_mangle]
451 /// Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read
452 pub extern "C" fn NodeFeatures_write(obj: &NodeFeatures) -> crate::c_types::derived::CVec_u8Z {
453         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
454 }
455 #[no_mangle]
456 pub(crate) extern "C" fn NodeFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
457         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeFeatures) })
458 }
459 #[no_mangle]
460 /// Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read
461 pub extern "C" fn ChannelFeatures_write(obj: &ChannelFeatures) -> crate::c_types::derived::CVec_u8Z {
462         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
463 }
464 #[no_mangle]
465 pub(crate) extern "C" fn ChannelFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
466         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelFeatures) })
467 }
468 #[no_mangle]
469 /// Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read
470 pub extern "C" fn InvoiceFeatures_write(obj: &InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z {
471         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
472 }
473 #[no_mangle]
474 pub(crate) extern "C" fn InvoiceFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
475         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceFeatures) })
476 }
477 #[no_mangle]
478 /// Read a InitFeatures from a byte array, created by InitFeatures_write
479 pub extern "C" fn InitFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitFeaturesDecodeErrorZ {
480         let res = crate::c_types::deserialize_obj(ser);
481         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
482         local_res
483 }
484 #[no_mangle]
485 /// Read a NodeFeatures from a byte array, created by NodeFeatures_write
486 pub extern "C" fn NodeFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeFeaturesDecodeErrorZ {
487         let res = crate::c_types::deserialize_obj(ser);
488         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
489         local_res
490 }
491 #[no_mangle]
492 /// Read a ChannelFeatures from a byte array, created by ChannelFeatures_write
493 pub extern "C" fn ChannelFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelFeaturesDecodeErrorZ {
494         let res = crate::c_types::deserialize_obj(ser);
495         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::ChannelFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
496         local_res
497 }
498 #[no_mangle]
499 /// Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write
500 pub extern "C" fn InvoiceFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InvoiceFeaturesDecodeErrorZ {
501         let res = crate::c_types::deserialize_obj(ser);
502         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::InvoiceFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
503         local_res
504 }