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