Merge pull request #51 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 /// Checks if two ChannelTypeFeaturess contain equal inner contents.
76 /// This ignores pointers and is_owned flags and looks at the values in fields.
77 /// Two objects with NULL inner values will be considered "equal" here.
78 #[no_mangle]
79 pub extern "C" fn ChannelTypeFeatures_eq(a: &ChannelTypeFeatures, b: &ChannelTypeFeatures) -> bool {
80         if a.inner == b.inner { return true; }
81         if a.inner.is_null() || b.inner.is_null() { return false; }
82         if a.get_native_ref() == b.get_native_ref() { true } else { false }
83 }
84 impl Clone for InitFeatures {
85         fn clone(&self) -> Self {
86                 Self {
87                         inner: if <*mut nativeInitFeatures>::is_null(self.inner) { std::ptr::null_mut() } else {
88                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
89                         is_owned: true,
90                 }
91         }
92 }
93 #[allow(unused)]
94 /// Used only if an object of this type is returned as a trait impl by a method
95 pub(crate) extern "C" fn InitFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
96         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInitFeatures)).clone() })) as *mut c_void
97 }
98 #[no_mangle]
99 /// Creates a copy of the InitFeatures
100 pub extern "C" fn InitFeatures_clone(orig: &InitFeatures) -> InitFeatures {
101         orig.clone()
102 }
103 impl Clone for NodeFeatures {
104         fn clone(&self) -> Self {
105                 Self {
106                         inner: if <*mut nativeNodeFeatures>::is_null(self.inner) { std::ptr::null_mut() } else {
107                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
108                         is_owned: true,
109                 }
110         }
111 }
112 #[allow(unused)]
113 /// Used only if an object of this type is returned as a trait impl by a method
114 pub(crate) extern "C" fn NodeFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
115         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeFeatures)).clone() })) as *mut c_void
116 }
117 #[no_mangle]
118 /// Creates a copy of the NodeFeatures
119 pub extern "C" fn NodeFeatures_clone(orig: &NodeFeatures) -> NodeFeatures {
120         orig.clone()
121 }
122 impl Clone for ChannelFeatures {
123         fn clone(&self) -> Self {
124                 Self {
125                         inner: if <*mut nativeChannelFeatures>::is_null(self.inner) { std::ptr::null_mut() } else {
126                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
127                         is_owned: true,
128                 }
129         }
130 }
131 #[allow(unused)]
132 /// Used only if an object of this type is returned as a trait impl by a method
133 pub(crate) extern "C" fn ChannelFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
134         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelFeatures)).clone() })) as *mut c_void
135 }
136 #[no_mangle]
137 /// Creates a copy of the ChannelFeatures
138 pub extern "C" fn ChannelFeatures_clone(orig: &ChannelFeatures) -> ChannelFeatures {
139         orig.clone()
140 }
141 impl Clone for InvoiceFeatures {
142         fn clone(&self) -> Self {
143                 Self {
144                         inner: if <*mut nativeInvoiceFeatures>::is_null(self.inner) { std::ptr::null_mut() } else {
145                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
146                         is_owned: true,
147                 }
148         }
149 }
150 #[allow(unused)]
151 /// Used only if an object of this type is returned as a trait impl by a method
152 pub(crate) extern "C" fn InvoiceFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
153         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoiceFeatures)).clone() })) as *mut c_void
154 }
155 #[no_mangle]
156 /// Creates a copy of the InvoiceFeatures
157 pub extern "C" fn InvoiceFeatures_clone(orig: &InvoiceFeatures) -> InvoiceFeatures {
158         orig.clone()
159 }
160 impl Clone for ChannelTypeFeatures {
161         fn clone(&self) -> Self {
162                 Self {
163                         inner: if <*mut nativeChannelTypeFeatures>::is_null(self.inner) { std::ptr::null_mut() } else {
164                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
165                         is_owned: true,
166                 }
167         }
168 }
169 #[allow(unused)]
170 /// Used only if an object of this type is returned as a trait impl by a method
171 pub(crate) extern "C" fn ChannelTypeFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
172         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelTypeFeatures)).clone() })) as *mut c_void
173 }
174 #[no_mangle]
175 /// Creates a copy of the ChannelTypeFeatures
176 pub extern "C" fn ChannelTypeFeatures_clone(orig: &ChannelTypeFeatures) -> ChannelTypeFeatures {
177         orig.clone()
178 }
179
180 use lightning::ln::features::InitFeatures as nativeInitFeaturesImport;
181 pub(crate) type nativeInitFeatures = nativeInitFeaturesImport;
182
183 /// Features used within an `init` message.
184 #[must_use]
185 #[repr(C)]
186 pub struct InitFeatures {
187         /// A pointer to the opaque Rust object.
188
189         /// Nearly everywhere, inner must be non-null, however in places where
190         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
191         pub inner: *mut nativeInitFeatures,
192         /// Indicates that this is the only struct which contains the same pointer.
193
194         /// Rust functions which take ownership of an object provided via an argument require
195         /// this to be true and invalidate the object pointed to by inner.
196         pub is_owned: bool,
197 }
198
199 impl Drop for InitFeatures {
200         fn drop(&mut self) {
201                 if self.is_owned && !<*mut nativeInitFeatures>::is_null(self.inner) {
202                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
203                 }
204         }
205 }
206 /// Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL.
207 #[no_mangle]
208 pub extern "C" fn InitFeatures_free(this_obj: InitFeatures) { }
209 #[allow(unused)]
210 /// Used only if an object of this type is returned as a trait impl by a method
211 pub(crate) extern "C" fn InitFeatures_free_void(this_ptr: *mut c_void) {
212         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInitFeatures); }
213 }
214 #[allow(unused)]
215 impl InitFeatures {
216         pub(crate) fn get_native_ref(&self) -> &'static nativeInitFeatures {
217                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
218         }
219         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInitFeatures {
220                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
221         }
222         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
223         pub(crate) fn take_inner(mut self) -> *mut nativeInitFeatures {
224                 assert!(self.is_owned);
225                 let ret = ObjOps::untweak_ptr(self.inner);
226                 self.inner = std::ptr::null_mut();
227                 ret
228         }
229 }
230
231 use lightning::ln::features::NodeFeatures as nativeNodeFeaturesImport;
232 pub(crate) type nativeNodeFeatures = nativeNodeFeaturesImport;
233
234 /// Features used within a `node_announcement` message.
235 #[must_use]
236 #[repr(C)]
237 pub struct NodeFeatures {
238         /// A pointer to the opaque Rust object.
239
240         /// Nearly everywhere, inner must be non-null, however in places where
241         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
242         pub inner: *mut nativeNodeFeatures,
243         /// Indicates that this is the only struct which contains the same pointer.
244
245         /// Rust functions which take ownership of an object provided via an argument require
246         /// this to be true and invalidate the object pointed to by inner.
247         pub is_owned: bool,
248 }
249
250 impl Drop for NodeFeatures {
251         fn drop(&mut self) {
252                 if self.is_owned && !<*mut nativeNodeFeatures>::is_null(self.inner) {
253                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
254                 }
255         }
256 }
257 /// Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL.
258 #[no_mangle]
259 pub extern "C" fn NodeFeatures_free(this_obj: NodeFeatures) { }
260 #[allow(unused)]
261 /// Used only if an object of this type is returned as a trait impl by a method
262 pub(crate) extern "C" fn NodeFeatures_free_void(this_ptr: *mut c_void) {
263         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeFeatures); }
264 }
265 #[allow(unused)]
266 impl NodeFeatures {
267         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeFeatures {
268                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
269         }
270         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeFeatures {
271                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
272         }
273         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
274         pub(crate) fn take_inner(mut self) -> *mut nativeNodeFeatures {
275                 assert!(self.is_owned);
276                 let ret = ObjOps::untweak_ptr(self.inner);
277                 self.inner = std::ptr::null_mut();
278                 ret
279         }
280 }
281
282 use lightning::ln::features::ChannelFeatures as nativeChannelFeaturesImport;
283 pub(crate) type nativeChannelFeatures = nativeChannelFeaturesImport;
284
285 /// Features used within a `channel_announcement` message.
286 #[must_use]
287 #[repr(C)]
288 pub struct ChannelFeatures {
289         /// A pointer to the opaque Rust object.
290
291         /// Nearly everywhere, inner must be non-null, however in places where
292         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
293         pub inner: *mut nativeChannelFeatures,
294         /// Indicates that this is the only struct which contains the same pointer.
295
296         /// Rust functions which take ownership of an object provided via an argument require
297         /// this to be true and invalidate the object pointed to by inner.
298         pub is_owned: bool,
299 }
300
301 impl Drop for ChannelFeatures {
302         fn drop(&mut self) {
303                 if self.is_owned && !<*mut nativeChannelFeatures>::is_null(self.inner) {
304                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
305                 }
306         }
307 }
308 /// Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL.
309 #[no_mangle]
310 pub extern "C" fn ChannelFeatures_free(this_obj: ChannelFeatures) { }
311 #[allow(unused)]
312 /// Used only if an object of this type is returned as a trait impl by a method
313 pub(crate) extern "C" fn ChannelFeatures_free_void(this_ptr: *mut c_void) {
314         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelFeatures); }
315 }
316 #[allow(unused)]
317 impl ChannelFeatures {
318         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelFeatures {
319                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
320         }
321         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelFeatures {
322                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
323         }
324         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
325         pub(crate) fn take_inner(mut self) -> *mut nativeChannelFeatures {
326                 assert!(self.is_owned);
327                 let ret = ObjOps::untweak_ptr(self.inner);
328                 self.inner = std::ptr::null_mut();
329                 ret
330         }
331 }
332
333 use lightning::ln::features::InvoiceFeatures as nativeInvoiceFeaturesImport;
334 pub(crate) type nativeInvoiceFeatures = nativeInvoiceFeaturesImport;
335
336 /// Features used within an invoice.
337 #[must_use]
338 #[repr(C)]
339 pub struct InvoiceFeatures {
340         /// A pointer to the opaque Rust object.
341
342         /// Nearly everywhere, inner must be non-null, however in places where
343         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
344         pub inner: *mut nativeInvoiceFeatures,
345         /// Indicates that this is the only struct which contains the same pointer.
346
347         /// Rust functions which take ownership of an object provided via an argument require
348         /// this to be true and invalidate the object pointed to by inner.
349         pub is_owned: bool,
350 }
351
352 impl Drop for InvoiceFeatures {
353         fn drop(&mut self) {
354                 if self.is_owned && !<*mut nativeInvoiceFeatures>::is_null(self.inner) {
355                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
356                 }
357         }
358 }
359 /// Frees any resources used by the InvoiceFeatures, if is_owned is set and inner is non-NULL.
360 #[no_mangle]
361 pub extern "C" fn InvoiceFeatures_free(this_obj: InvoiceFeatures) { }
362 #[allow(unused)]
363 /// Used only if an object of this type is returned as a trait impl by a method
364 pub(crate) extern "C" fn InvoiceFeatures_free_void(this_ptr: *mut c_void) {
365         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInvoiceFeatures); }
366 }
367 #[allow(unused)]
368 impl InvoiceFeatures {
369         pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceFeatures {
370                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
371         }
372         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceFeatures {
373                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
374         }
375         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
376         pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceFeatures {
377                 assert!(self.is_owned);
378                 let ret = ObjOps::untweak_ptr(self.inner);
379                 self.inner = std::ptr::null_mut();
380                 ret
381         }
382 }
383
384 use lightning::ln::features::ChannelTypeFeatures as nativeChannelTypeFeaturesImport;
385 pub(crate) type nativeChannelTypeFeatures = nativeChannelTypeFeaturesImport;
386
387 /// Features used within the channel_type field in an OpenChannel message.
388 ///
389 /// A channel is always of some known \"type\", describing the transaction formats used and the exact
390 /// semantics of our interaction with our peer.
391 ///
392 /// Note that because a channel is a specific type which is proposed by the opener and accepted by
393 /// the counterparty, only required features are allowed here.
394 ///
395 /// This is serialized differently from other feature types - it is not prefixed by a length, and
396 /// thus must only appear inside a TLV where its length is known in advance.
397 #[must_use]
398 #[repr(C)]
399 pub struct ChannelTypeFeatures {
400         /// A pointer to the opaque Rust object.
401
402         /// Nearly everywhere, inner must be non-null, however in places where
403         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
404         pub inner: *mut nativeChannelTypeFeatures,
405         /// Indicates that this is the only struct which contains the same pointer.
406
407         /// Rust functions which take ownership of an object provided via an argument require
408         /// this to be true and invalidate the object pointed to by inner.
409         pub is_owned: bool,
410 }
411
412 impl Drop for ChannelTypeFeatures {
413         fn drop(&mut self) {
414                 if self.is_owned && !<*mut nativeChannelTypeFeatures>::is_null(self.inner) {
415                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
416                 }
417         }
418 }
419 /// Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL.
420 #[no_mangle]
421 pub extern "C" fn ChannelTypeFeatures_free(this_obj: ChannelTypeFeatures) { }
422 #[allow(unused)]
423 /// Used only if an object of this type is returned as a trait impl by a method
424 pub(crate) extern "C" fn ChannelTypeFeatures_free_void(this_ptr: *mut c_void) {
425         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelTypeFeatures); }
426 }
427 #[allow(unused)]
428 impl ChannelTypeFeatures {
429         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelTypeFeatures {
430                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
431         }
432         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelTypeFeatures {
433                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
434         }
435         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
436         pub(crate) fn take_inner(mut self) -> *mut nativeChannelTypeFeatures {
437                 assert!(self.is_owned);
438                 let ret = ObjOps::untweak_ptr(self.inner);
439                 self.inner = std::ptr::null_mut();
440                 ret
441         }
442 }
443 /// Create a blank Features with no features set
444 #[must_use]
445 #[no_mangle]
446 pub extern "C" fn InitFeatures_empty() -> InitFeatures {
447         let mut ret = lightning::ln::features::InitFeatures::empty();
448         InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
449 }
450
451 /// Creates a Features with the bits set which are known by the implementation
452 #[must_use]
453 #[no_mangle]
454 pub extern "C" fn InitFeatures_known() -> InitFeatures {
455         let mut ret = lightning::ln::features::InitFeatures::known();
456         InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
457 }
458
459 /// Returns true if this `Features` object contains unknown feature flags which are set as
460 /// \"required\".
461 #[must_use]
462 #[no_mangle]
463 pub extern "C" fn InitFeatures_requires_unknown_bits(this_arg: &InitFeatures) -> bool {
464         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits();
465         ret
466 }
467
468 /// Create a blank Features with no features set
469 #[must_use]
470 #[no_mangle]
471 pub extern "C" fn NodeFeatures_empty() -> NodeFeatures {
472         let mut ret = lightning::ln::features::NodeFeatures::empty();
473         NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
474 }
475
476 /// Creates a Features with the bits set which are known by the implementation
477 #[must_use]
478 #[no_mangle]
479 pub extern "C" fn NodeFeatures_known() -> NodeFeatures {
480         let mut ret = lightning::ln::features::NodeFeatures::known();
481         NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
482 }
483
484 /// Returns true if this `Features` object contains unknown feature flags which are set as
485 /// \"required\".
486 #[must_use]
487 #[no_mangle]
488 pub extern "C" fn NodeFeatures_requires_unknown_bits(this_arg: &NodeFeatures) -> bool {
489         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits();
490         ret
491 }
492
493 /// Create a blank Features with no features set
494 #[must_use]
495 #[no_mangle]
496 pub extern "C" fn ChannelFeatures_empty() -> ChannelFeatures {
497         let mut ret = lightning::ln::features::ChannelFeatures::empty();
498         ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
499 }
500
501 /// Creates a Features with the bits set which are known by the implementation
502 #[must_use]
503 #[no_mangle]
504 pub extern "C" fn ChannelFeatures_known() -> ChannelFeatures {
505         let mut ret = lightning::ln::features::ChannelFeatures::known();
506         ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
507 }
508
509 /// Returns true if this `Features` object contains unknown feature flags which are set as
510 /// \"required\".
511 #[must_use]
512 #[no_mangle]
513 pub extern "C" fn ChannelFeatures_requires_unknown_bits(this_arg: &ChannelFeatures) -> bool {
514         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits();
515         ret
516 }
517
518 /// Create a blank Features with no features set
519 #[must_use]
520 #[no_mangle]
521 pub extern "C" fn InvoiceFeatures_empty() -> InvoiceFeatures {
522         let mut ret = lightning::ln::features::InvoiceFeatures::empty();
523         InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
524 }
525
526 /// Creates a Features with the bits set which are known by the implementation
527 #[must_use]
528 #[no_mangle]
529 pub extern "C" fn InvoiceFeatures_known() -> InvoiceFeatures {
530         let mut ret = lightning::ln::features::InvoiceFeatures::known();
531         InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
532 }
533
534 /// Returns true if this `Features` object contains unknown feature flags which are set as
535 /// \"required\".
536 #[must_use]
537 #[no_mangle]
538 pub extern "C" fn InvoiceFeatures_requires_unknown_bits(this_arg: &InvoiceFeatures) -> bool {
539         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits();
540         ret
541 }
542
543 /// Create a blank Features with no features set
544 #[must_use]
545 #[no_mangle]
546 pub extern "C" fn ChannelTypeFeatures_empty() -> ChannelTypeFeatures {
547         let mut ret = lightning::ln::features::ChannelTypeFeatures::empty();
548         ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
549 }
550
551 /// Creates a Features with the bits set which are known by the implementation
552 #[must_use]
553 #[no_mangle]
554 pub extern "C" fn ChannelTypeFeatures_known() -> ChannelTypeFeatures {
555         let mut ret = lightning::ln::features::ChannelTypeFeatures::known();
556         ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
557 }
558
559 /// Returns true if this `Features` object contains unknown feature flags which are set as
560 /// \"required\".
561 #[must_use]
562 #[no_mangle]
563 pub extern "C" fn ChannelTypeFeatures_requires_unknown_bits(this_arg: &ChannelTypeFeatures) -> bool {
564         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits();
565         ret
566 }
567
568 #[no_mangle]
569 /// Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read
570 pub extern "C" fn InitFeatures_write(obj: &InitFeatures) -> crate::c_types::derived::CVec_u8Z {
571         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
572 }
573 #[no_mangle]
574 pub(crate) extern "C" fn InitFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
575         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInitFeatures) })
576 }
577 #[no_mangle]
578 /// Read a InitFeatures from a byte array, created by InitFeatures_write
579 pub extern "C" fn InitFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitFeaturesDecodeErrorZ {
580         let res: Result<lightning::ln::features::InitFeatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
581         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() };
582         local_res
583 }
584 #[no_mangle]
585 /// Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read
586 pub extern "C" fn ChannelFeatures_write(obj: &ChannelFeatures) -> crate::c_types::derived::CVec_u8Z {
587         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
588 }
589 #[no_mangle]
590 pub(crate) extern "C" fn ChannelFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
591         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelFeatures) })
592 }
593 #[no_mangle]
594 /// Read a ChannelFeatures from a byte array, created by ChannelFeatures_write
595 pub extern "C" fn ChannelFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelFeaturesDecodeErrorZ {
596         let res: Result<lightning::ln::features::ChannelFeatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
597         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() };
598         local_res
599 }
600 #[no_mangle]
601 /// Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read
602 pub extern "C" fn NodeFeatures_write(obj: &NodeFeatures) -> crate::c_types::derived::CVec_u8Z {
603         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
604 }
605 #[no_mangle]
606 pub(crate) extern "C" fn NodeFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
607         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeFeatures) })
608 }
609 #[no_mangle]
610 /// Read a NodeFeatures from a byte array, created by NodeFeatures_write
611 pub extern "C" fn NodeFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeFeaturesDecodeErrorZ {
612         let res: Result<lightning::ln::features::NodeFeatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
613         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() };
614         local_res
615 }
616 #[no_mangle]
617 /// Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read
618 pub extern "C" fn InvoiceFeatures_write(obj: &InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z {
619         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
620 }
621 #[no_mangle]
622 pub(crate) extern "C" fn InvoiceFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
623         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceFeatures) })
624 }
625 #[no_mangle]
626 /// Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write
627 pub extern "C" fn InvoiceFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InvoiceFeaturesDecodeErrorZ {
628         let res: Result<lightning::ln::features::InvoiceFeatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
629         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() };
630         local_res
631 }
632 #[no_mangle]
633 /// Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read
634 pub extern "C" fn ChannelTypeFeatures_write(obj: &ChannelTypeFeatures) -> crate::c_types::derived::CVec_u8Z {
635         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
636 }
637 #[no_mangle]
638 pub(crate) extern "C" fn ChannelTypeFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
639         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelTypeFeatures) })
640 }
641 #[no_mangle]
642 /// Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write
643 pub extern "C" fn ChannelTypeFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelTypeFeaturesDecodeErrorZ {
644         let res: Result<lightning::ln::features::ChannelTypeFeatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
645         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::ChannelTypeFeatures { 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() };
646         local_res
647 }