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 std::str::FromStr;
26 use core::convert::Infallible;
27 use bitcoin::hashes::Hash;
28 use crate::c_types::*;
32 use std::str::FromStr;
34 use core::convert::Infallible;
35 use bitcoin::hashes::Hash;
36 use crate::c_types::*;
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.
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 }
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.
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 }
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.
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 }
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.
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 }
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.
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 }
84 impl Clone for InitFeatures {
85 fn clone(&self) -> 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()) },
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
99 /// Creates a copy of the InitFeatures
100 pub extern "C" fn InitFeatures_clone(orig: &InitFeatures) -> InitFeatures {
103 impl Clone for NodeFeatures {
104 fn clone(&self) -> 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()) },
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
118 /// Creates a copy of the NodeFeatures
119 pub extern "C" fn NodeFeatures_clone(orig: &NodeFeatures) -> NodeFeatures {
122 impl Clone for ChannelFeatures {
123 fn clone(&self) -> 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()) },
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
137 /// Creates a copy of the ChannelFeatures
138 pub extern "C" fn ChannelFeatures_clone(orig: &ChannelFeatures) -> ChannelFeatures {
141 impl Clone for InvoiceFeatures {
142 fn clone(&self) -> 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()) },
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
156 /// Creates a copy of the InvoiceFeatures
157 pub extern "C" fn InvoiceFeatures_clone(orig: &InvoiceFeatures) -> InvoiceFeatures {
160 impl Clone for ChannelTypeFeatures {
161 fn clone(&self) -> 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()) },
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
175 /// Creates a copy of the ChannelTypeFeatures
176 pub extern "C" fn ChannelTypeFeatures_clone(orig: &ChannelTypeFeatures) -> ChannelTypeFeatures {
180 use lightning::ln::features::InitFeatures as nativeInitFeaturesImport;
181 pub(crate) type nativeInitFeatures = nativeInitFeaturesImport;
183 /// Features used within an `init` message.
186 pub struct InitFeatures {
187 /// A pointer to the opaque Rust object.
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.
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.
199 impl Drop for InitFeatures {
201 if self.is_owned && !<*mut nativeInitFeatures>::is_null(self.inner) {
202 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
206 /// Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL.
208 pub extern "C" fn InitFeatures_free(this_obj: InitFeatures) { }
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); }
216 pub(crate) fn get_native_ref(&self) -> &'static nativeInitFeatures {
217 unsafe { &*ObjOps::untweak_ptr(self.inner) }
219 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInitFeatures {
220 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
231 use lightning::ln::features::NodeFeatures as nativeNodeFeaturesImport;
232 pub(crate) type nativeNodeFeatures = nativeNodeFeaturesImport;
234 /// Features used within a `node_announcement` message.
237 pub struct NodeFeatures {
238 /// A pointer to the opaque Rust object.
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.
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.
250 impl Drop for NodeFeatures {
252 if self.is_owned && !<*mut nativeNodeFeatures>::is_null(self.inner) {
253 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
257 /// Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL.
259 pub extern "C" fn NodeFeatures_free(this_obj: NodeFeatures) { }
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); }
267 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeFeatures {
268 unsafe { &*ObjOps::untweak_ptr(self.inner) }
270 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeFeatures {
271 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
282 use lightning::ln::features::ChannelFeatures as nativeChannelFeaturesImport;
283 pub(crate) type nativeChannelFeatures = nativeChannelFeaturesImport;
285 /// Features used within a `channel_announcement` message.
288 pub struct ChannelFeatures {
289 /// A pointer to the opaque Rust object.
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.
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.
301 impl Drop for ChannelFeatures {
303 if self.is_owned && !<*mut nativeChannelFeatures>::is_null(self.inner) {
304 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
308 /// Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL.
310 pub extern "C" fn ChannelFeatures_free(this_obj: ChannelFeatures) { }
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); }
317 impl ChannelFeatures {
318 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelFeatures {
319 unsafe { &*ObjOps::untweak_ptr(self.inner) }
321 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelFeatures {
322 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
333 use lightning::ln::features::InvoiceFeatures as nativeInvoiceFeaturesImport;
334 pub(crate) type nativeInvoiceFeatures = nativeInvoiceFeaturesImport;
336 /// Features used within an invoice.
339 pub struct InvoiceFeatures {
340 /// A pointer to the opaque Rust object.
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.
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.
352 impl Drop for InvoiceFeatures {
354 if self.is_owned && !<*mut nativeInvoiceFeatures>::is_null(self.inner) {
355 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
359 /// Frees any resources used by the InvoiceFeatures, if is_owned is set and inner is non-NULL.
361 pub extern "C" fn InvoiceFeatures_free(this_obj: InvoiceFeatures) { }
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); }
368 impl InvoiceFeatures {
369 pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceFeatures {
370 unsafe { &*ObjOps::untweak_ptr(self.inner) }
372 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceFeatures {
373 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
384 use lightning::ln::features::ChannelTypeFeatures as nativeChannelTypeFeaturesImport;
385 pub(crate) type nativeChannelTypeFeatures = nativeChannelTypeFeaturesImport;
387 /// Features used within the channel_type field in an OpenChannel message.
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.
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.
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.
399 pub struct ChannelTypeFeatures {
400 /// A pointer to the opaque Rust object.
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.
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.
412 impl Drop for ChannelTypeFeatures {
414 if self.is_owned && !<*mut nativeChannelTypeFeatures>::is_null(self.inner) {
415 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
419 /// Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL.
421 pub extern "C" fn ChannelTypeFeatures_free(this_obj: ChannelTypeFeatures) { }
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); }
428 impl ChannelTypeFeatures {
429 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelTypeFeatures {
430 unsafe { &*ObjOps::untweak_ptr(self.inner) }
432 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelTypeFeatures {
433 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
443 /// Create a blank Features with no features set
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 }
451 /// Creates a Features with the bits set which are known by the implementation
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 }
459 /// Returns true if this `Features` object contains unknown feature flags which are set as
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();
468 /// Create a blank Features with no features set
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 }
476 /// Creates a Features with the bits set which are known by the implementation
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 }
484 /// Returns true if this `Features` object contains unknown feature flags which are set as
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();
493 /// Create a blank Features with no features set
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 }
501 /// Creates a Features with the bits set which are known by the implementation
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 }
509 /// Returns true if this `Features` object contains unknown feature flags which are set as
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();
518 /// Create a blank Features with no features set
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 }
526 /// Creates a Features with the bits set which are known by the implementation
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 }
534 /// Returns true if this `Features` object contains unknown feature flags which are set as
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();
543 /// Create a blank Features with no features set
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 }
551 /// Creates a Features with the bits set which are known by the implementation
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 }
559 /// Returns true if this `Features` object contains unknown feature flags which are set as
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();
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())
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) })
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() };
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())
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) })
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() };
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())
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) })
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() };
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())
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) })
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() };
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())
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) })
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() };