1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
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.
9 //! Feature flag definitions for the Lightning protocol according to [BOLT #9].
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).
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.
21 //! [BOLT #9]: https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md
22 //! [messages]: crate::ln::msgs
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};
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};
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.
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 }
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.
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 }
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.
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 }
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.
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 }
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.
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 }
88 impl Clone for InitFeatures {
89 fn clone(&self) -> 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()) },
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
103 /// Creates a copy of the InitFeatures
104 pub extern "C" fn InitFeatures_clone(orig: &InitFeatures) -> InitFeatures {
107 impl Clone for NodeFeatures {
108 fn clone(&self) -> 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()) },
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
122 /// Creates a copy of the NodeFeatures
123 pub extern "C" fn NodeFeatures_clone(orig: &NodeFeatures) -> NodeFeatures {
126 impl Clone for ChannelFeatures {
127 fn clone(&self) -> 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()) },
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
141 /// Creates a copy of the ChannelFeatures
142 pub extern "C" fn ChannelFeatures_clone(orig: &ChannelFeatures) -> ChannelFeatures {
145 impl Clone for InvoiceFeatures {
146 fn clone(&self) -> 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()) },
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
160 /// Creates a copy of the InvoiceFeatures
161 pub extern "C" fn InvoiceFeatures_clone(orig: &InvoiceFeatures) -> InvoiceFeatures {
164 impl Clone for ChannelTypeFeatures {
165 fn clone(&self) -> 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()) },
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
179 /// Creates a copy of the ChannelTypeFeatures
180 pub extern "C" fn ChannelTypeFeatures_clone(orig: &ChannelTypeFeatures) -> ChannelTypeFeatures {
184 use lightning::ln::features::InitFeatures as nativeInitFeaturesImport;
185 pub(crate) type nativeInitFeatures = nativeInitFeaturesImport;
187 /// Features used within an `init` message.
190 pub struct InitFeatures {
191 /// A pointer to the opaque Rust object.
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.
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.
203 impl Drop for InitFeatures {
205 if self.is_owned && !<*mut nativeInitFeatures>::is_null(self.inner) {
206 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
210 /// Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL.
212 pub extern "C" fn InitFeatures_free(this_obj: InitFeatures) { }
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); }
220 pub(crate) fn get_native_ref(&self) -> &'static nativeInitFeatures {
221 unsafe { &*ObjOps::untweak_ptr(self.inner) }
223 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInitFeatures {
224 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
235 use lightning::ln::features::NodeFeatures as nativeNodeFeaturesImport;
236 pub(crate) type nativeNodeFeatures = nativeNodeFeaturesImport;
238 /// Features used within a `node_announcement` message.
241 pub struct NodeFeatures {
242 /// A pointer to the opaque Rust object.
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.
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.
254 impl Drop for NodeFeatures {
256 if self.is_owned && !<*mut nativeNodeFeatures>::is_null(self.inner) {
257 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
261 /// Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL.
263 pub extern "C" fn NodeFeatures_free(this_obj: NodeFeatures) { }
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); }
271 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeFeatures {
272 unsafe { &*ObjOps::untweak_ptr(self.inner) }
274 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeFeatures {
275 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
286 use lightning::ln::features::ChannelFeatures as nativeChannelFeaturesImport;
287 pub(crate) type nativeChannelFeatures = nativeChannelFeaturesImport;
289 /// Features used within a `channel_announcement` message.
292 pub struct ChannelFeatures {
293 /// A pointer to the opaque Rust object.
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.
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.
305 impl Drop for ChannelFeatures {
307 if self.is_owned && !<*mut nativeChannelFeatures>::is_null(self.inner) {
308 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
312 /// Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL.
314 pub extern "C" fn ChannelFeatures_free(this_obj: ChannelFeatures) { }
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); }
321 impl ChannelFeatures {
322 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelFeatures {
323 unsafe { &*ObjOps::untweak_ptr(self.inner) }
325 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelFeatures {
326 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
337 use lightning::ln::features::InvoiceFeatures as nativeInvoiceFeaturesImport;
338 pub(crate) type nativeInvoiceFeatures = nativeInvoiceFeaturesImport;
340 /// Features used within an invoice.
343 pub struct InvoiceFeatures {
344 /// A pointer to the opaque Rust object.
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.
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.
356 impl Drop for InvoiceFeatures {
358 if self.is_owned && !<*mut nativeInvoiceFeatures>::is_null(self.inner) {
359 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
363 /// Frees any resources used by the InvoiceFeatures, if is_owned is set and inner is non-NULL.
365 pub extern "C" fn InvoiceFeatures_free(this_obj: InvoiceFeatures) { }
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); }
372 impl InvoiceFeatures {
373 pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceFeatures {
374 unsafe { &*ObjOps::untweak_ptr(self.inner) }
376 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceFeatures {
377 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
388 use lightning::ln::features::ChannelTypeFeatures as nativeChannelTypeFeaturesImport;
389 pub(crate) type nativeChannelTypeFeatures = nativeChannelTypeFeaturesImport;
391 /// Features used within the channel_type field in an OpenChannel message.
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.
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.
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.
403 pub struct ChannelTypeFeatures {
404 /// A pointer to the opaque Rust object.
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.
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.
416 impl Drop for ChannelTypeFeatures {
418 if self.is_owned && !<*mut nativeChannelTypeFeatures>::is_null(self.inner) {
419 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
423 /// Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL.
425 pub extern "C" fn ChannelTypeFeatures_free(this_obj: ChannelTypeFeatures) { }
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); }
432 impl ChannelTypeFeatures {
433 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelTypeFeatures {
434 unsafe { &*ObjOps::untweak_ptr(self.inner) }
436 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelTypeFeatures {
437 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
447 /// Create a blank Features with no features set
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 }
455 /// Creates a Features with the bits set which are known by the implementation
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 }
463 /// Returns true if this `Features` object contains unknown feature flags which are set as
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();
472 /// Create a blank Features with no features set
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 }
480 /// Creates a Features with the bits set which are known by the implementation
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 }
488 /// Returns true if this `Features` object contains unknown feature flags which are set as
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();
497 /// Create a blank Features with no features set
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 }
505 /// Creates a Features with the bits set which are known by the implementation
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 }
513 /// Returns true if this `Features` object contains unknown feature flags which are set as
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();
522 /// Create a blank Features with no features set
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 }
530 /// Creates a Features with the bits set which are known by the implementation
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 }
538 /// Returns true if this `Features` object contains unknown feature flags which are set as
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();
547 /// Create a blank Features with no features set
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 }
555 /// Creates a Features with the bits set which are known by the implementation
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 }
563 /// Returns true if this `Features` object contains unknown feature flags which are set as
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();
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())
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) })
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() };
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())
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) })
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() };
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())
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) })
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() };
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())
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) })
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() };
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())
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) })
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() };