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