X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Fln%2Ffeatures.rs;h=7bee3b0d7a0c5d1fe85607570479e0621eaefecd;hb=5271372bfe3ddc870c806f7b7ee13c4a7660e7e5;hp=8a61a8536c389dda9f542f075b0753922b7839e3;hpb=6658ad877ed253301df2c729b1c6a2a859515777;p=ldk-c-bindings diff --git a/lightning-c-bindings/src/lightning/ln/features.rs b/lightning-c-bindings/src/lightning/ln/features.rs index 8a61a85..7bee3b0 100644 --- a/lightning-c-bindings/src/lightning/ln/features.rs +++ b/lightning-c-bindings/src/lightning/ln/features.rs @@ -23,6 +23,7 @@ use std::str::FromStr; use std::ffi::c_void; +use core::convert::Infallible; use bitcoin::hashes::Hash; use crate::c_types::*; @@ -30,6 +31,7 @@ mod sealed { use std::str::FromStr; use std::ffi::c_void; +use core::convert::Infallible; use bitcoin::hashes::Hash; use crate::c_types::*; @@ -41,7 +43,7 @@ use crate::c_types::*; pub extern "C" fn InitFeatures_eq(a: &InitFeatures, b: &InitFeatures) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } - if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false } + if a.get_native_ref() == b.get_native_ref() { true } else { false } } /// Checks if two NodeFeaturess contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. @@ -50,7 +52,7 @@ pub extern "C" fn InitFeatures_eq(a: &InitFeatures, b: &InitFeatures) -> bool { pub extern "C" fn NodeFeatures_eq(a: &NodeFeatures, b: &NodeFeatures) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } - if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false } + if a.get_native_ref() == b.get_native_ref() { true } else { false } } /// Checks if two ChannelFeaturess contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. @@ -59,7 +61,7 @@ pub extern "C" fn NodeFeatures_eq(a: &NodeFeatures, b: &NodeFeatures) -> bool { pub extern "C" fn ChannelFeatures_eq(a: &ChannelFeatures, b: &ChannelFeatures) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } - if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false } + if a.get_native_ref() == b.get_native_ref() { true } else { false } } /// Checks if two InvoiceFeaturess contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. @@ -68,13 +70,13 @@ pub extern "C" fn ChannelFeatures_eq(a: &ChannelFeatures, b: &ChannelFeatures) - pub extern "C" fn InvoiceFeatures_eq(a: &InvoiceFeatures, b: &InvoiceFeatures) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } - if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false } + if a.get_native_ref() == b.get_native_ref() { true } else { false } } impl Clone for InitFeatures { fn clone(&self) -> Self { Self { inner: if <*mut nativeInitFeatures>::is_null(self.inner) { std::ptr::null_mut() } else { - Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } } @@ -93,7 +95,7 @@ impl Clone for NodeFeatures { fn clone(&self) -> Self { Self { inner: if <*mut nativeNodeFeatures>::is_null(self.inner) { std::ptr::null_mut() } else { - Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } } @@ -112,7 +114,7 @@ impl Clone for ChannelFeatures { fn clone(&self) -> Self { Self { inner: if <*mut nativeChannelFeatures>::is_null(self.inner) { std::ptr::null_mut() } else { - Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } } @@ -131,7 +133,7 @@ impl Clone for InvoiceFeatures { fn clone(&self) -> Self { Self { inner: if <*mut nativeInvoiceFeatures>::is_null(self.inner) { std::ptr::null_mut() } else { - Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } } @@ -148,7 +150,7 @@ pub extern "C" fn InvoiceFeatures_clone(orig: &InvoiceFeatures) -> InvoiceFeatur } use lightning::ln::features::InitFeatures as nativeInitFeaturesImport; -type nativeInitFeatures = nativeInitFeaturesImport; +pub(crate) type nativeInitFeatures = nativeInitFeaturesImport; /// Features used within an `init` message. #[must_use] @@ -169,7 +171,7 @@ pub struct InitFeatures { impl Drop for InitFeatures { fn drop(&mut self) { if self.is_owned && !<*mut nativeInitFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } @@ -178,22 +180,28 @@ impl Drop for InitFeatures { pub extern "C" fn InitFeatures_free(this_obj: InitFeatures) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn InitFeatures_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn InitFeatures_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInitFeatures); } } #[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl InitFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeInitFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInitFeatures { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy pub(crate) fn take_inner(mut self) -> *mut nativeInitFeatures { assert!(self.is_owned); - let ret = self.inner; + let ret = ObjOps::untweak_ptr(self.inner); self.inner = std::ptr::null_mut(); ret } } use lightning::ln::features::NodeFeatures as nativeNodeFeaturesImport; -type nativeNodeFeatures = nativeNodeFeaturesImport; +pub(crate) type nativeNodeFeatures = nativeNodeFeaturesImport; /// Features used within a `node_announcement` message. #[must_use] @@ -214,7 +222,7 @@ pub struct NodeFeatures { impl Drop for NodeFeatures { fn drop(&mut self) { if self.is_owned && !<*mut nativeNodeFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } @@ -223,22 +231,28 @@ impl Drop for NodeFeatures { pub extern "C" fn NodeFeatures_free(this_obj: NodeFeatures) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn NodeFeatures_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn NodeFeatures_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeFeatures); } } #[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl NodeFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeNodeFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeFeatures { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy pub(crate) fn take_inner(mut self) -> *mut nativeNodeFeatures { assert!(self.is_owned); - let ret = self.inner; + let ret = ObjOps::untweak_ptr(self.inner); self.inner = std::ptr::null_mut(); ret } } use lightning::ln::features::ChannelFeatures as nativeChannelFeaturesImport; -type nativeChannelFeatures = nativeChannelFeaturesImport; +pub(crate) type nativeChannelFeatures = nativeChannelFeaturesImport; /// Features used within a `channel_announcement` message. #[must_use] @@ -259,7 +273,7 @@ pub struct ChannelFeatures { impl Drop for ChannelFeatures { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } @@ -268,22 +282,28 @@ impl Drop for ChannelFeatures { pub extern "C" fn ChannelFeatures_free(this_obj: ChannelFeatures) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ChannelFeatures_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn ChannelFeatures_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelFeatures); } } #[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ChannelFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeChannelFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelFeatures { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy pub(crate) fn take_inner(mut self) -> *mut nativeChannelFeatures { assert!(self.is_owned); - let ret = self.inner; + let ret = ObjOps::untweak_ptr(self.inner); self.inner = std::ptr::null_mut(); ret } } use lightning::ln::features::InvoiceFeatures as nativeInvoiceFeaturesImport; -type nativeInvoiceFeatures = nativeInvoiceFeaturesImport; +pub(crate) type nativeInvoiceFeatures = nativeInvoiceFeaturesImport; /// Features used within an invoice. #[must_use] @@ -304,7 +324,7 @@ pub struct InvoiceFeatures { impl Drop for InvoiceFeatures { fn drop(&mut self) { if self.is_owned && !<*mut nativeInvoiceFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } @@ -313,15 +333,21 @@ impl Drop for InvoiceFeatures { pub extern "C" fn InvoiceFeatures_free(this_obj: InvoiceFeatures) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn InvoiceFeatures_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn InvoiceFeatures_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInvoiceFeatures); } } #[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl InvoiceFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceFeatures { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceFeatures { assert!(self.is_owned); - let ret = self.inner; + let ret = ObjOps::untweak_ptr(self.inner); self.inner = std::ptr::null_mut(); ret } @@ -331,7 +357,7 @@ impl InvoiceFeatures { #[no_mangle] pub extern "C" fn InitFeatures_empty() -> InitFeatures { let mut ret = lightning::ln::features::InitFeatures::empty(); - InitFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } + InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Creates a Features with the bits set which are known by the implementation @@ -339,7 +365,16 @@ pub extern "C" fn InitFeatures_empty() -> InitFeatures { #[no_mangle] pub extern "C" fn InitFeatures_known() -> InitFeatures { let mut ret = lightning::ln::features::InitFeatures::known(); - InitFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } + InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_unknown_bits(this_arg: &InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret } /// Create a blank Features with no features set @@ -347,7 +382,7 @@ pub extern "C" fn InitFeatures_known() -> InitFeatures { #[no_mangle] pub extern "C" fn NodeFeatures_empty() -> NodeFeatures { let mut ret = lightning::ln::features::NodeFeatures::empty(); - NodeFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } + NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Creates a Features with the bits set which are known by the implementation @@ -355,7 +390,16 @@ pub extern "C" fn NodeFeatures_empty() -> NodeFeatures { #[no_mangle] pub extern "C" fn NodeFeatures_known() -> NodeFeatures { let mut ret = lightning::ln::features::NodeFeatures::known(); - NodeFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } + NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_unknown_bits(this_arg: &NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret } /// Create a blank Features with no features set @@ -363,7 +407,7 @@ pub extern "C" fn NodeFeatures_known() -> NodeFeatures { #[no_mangle] pub extern "C" fn ChannelFeatures_empty() -> ChannelFeatures { let mut ret = lightning::ln::features::ChannelFeatures::empty(); - ChannelFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } + ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Creates a Features with the bits set which are known by the implementation @@ -371,7 +415,16 @@ pub extern "C" fn ChannelFeatures_empty() -> ChannelFeatures { #[no_mangle] pub extern "C" fn ChannelFeatures_known() -> ChannelFeatures { let mut ret = lightning::ln::features::ChannelFeatures::known(); - ChannelFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } + ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_requires_unknown_bits(this_arg: &ChannelFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret } /// Create a blank Features with no features set @@ -379,7 +432,7 @@ pub extern "C" fn ChannelFeatures_known() -> ChannelFeatures { #[no_mangle] pub extern "C" fn InvoiceFeatures_empty() -> InvoiceFeatures { let mut ret = lightning::ln::features::InvoiceFeatures::empty(); - InvoiceFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } + InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Creates a Features with the bits set which are known by the implementation @@ -387,14 +440,23 @@ pub extern "C" fn InvoiceFeatures_empty() -> InvoiceFeatures { #[no_mangle] pub extern "C" fn InvoiceFeatures_known() -> InvoiceFeatures { let mut ret = lightning::ln::features::InvoiceFeatures::known(); - InvoiceFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } + InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceFeatures_requires_unknown_bits(this_arg: &InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret } /// Returns whether the `payment_secret` feature is supported. #[must_use] #[no_mangle] pub extern "C" fn InitFeatures_supports_payment_secret(this_arg: &InitFeatures) -> bool { - let mut ret = unsafe { &*this_arg.inner }.supports_payment_secret(); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); ret } @@ -402,7 +464,7 @@ pub extern "C" fn InitFeatures_supports_payment_secret(this_arg: &InitFeatures) #[must_use] #[no_mangle] pub extern "C" fn NodeFeatures_supports_payment_secret(this_arg: &NodeFeatures) -> bool { - let mut ret = unsafe { &*this_arg.inner }.supports_payment_secret(); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); ret } @@ -410,14 +472,14 @@ pub extern "C" fn NodeFeatures_supports_payment_secret(this_arg: &NodeFeatures) #[must_use] #[no_mangle] pub extern "C" fn InvoiceFeatures_supports_payment_secret(this_arg: &InvoiceFeatures) -> bool { - let mut ret = unsafe { &*this_arg.inner }.supports_payment_secret(); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); ret } #[no_mangle] /// Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read pub extern "C" fn InitFeatures_write(obj: &InitFeatures) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[no_mangle] pub(crate) extern "C" fn InitFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { @@ -426,7 +488,7 @@ pub(crate) extern "C" fn InitFeatures_write_void(obj: *const c_void) -> crate::c #[no_mangle] /// Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read pub extern "C" fn NodeFeatures_write(obj: &NodeFeatures) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[no_mangle] pub(crate) extern "C" fn NodeFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { @@ -435,7 +497,7 @@ pub(crate) extern "C" fn NodeFeatures_write_void(obj: *const c_void) -> crate::c #[no_mangle] /// Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read pub extern "C" fn ChannelFeatures_write(obj: &ChannelFeatures) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[no_mangle] pub(crate) extern "C" fn ChannelFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { @@ -444,7 +506,7 @@ pub(crate) extern "C" fn ChannelFeatures_write_void(obj: *const c_void) -> crate #[no_mangle] /// Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read pub extern "C" fn InvoiceFeatures_write(obj: &InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[no_mangle] pub(crate) extern "C" fn InvoiceFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { @@ -454,27 +516,27 @@ pub(crate) extern "C" fn InvoiceFeatures_write_void(obj: *const c_void) -> crate /// Read a InitFeatures from a byte array, created by InitFeatures_write pub extern "C" fn InitFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitFeaturesDecodeErrorZ { let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::InitFeatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + 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() }; local_res } #[no_mangle] /// Read a NodeFeatures from a byte array, created by NodeFeatures_write pub extern "C" fn NodeFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeFeaturesDecodeErrorZ { let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::NodeFeatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + 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() }; local_res } #[no_mangle] /// Read a ChannelFeatures from a byte array, created by ChannelFeatures_write pub extern "C" fn ChannelFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelFeaturesDecodeErrorZ { let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::ChannelFeatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + 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() }; local_res } #[no_mangle] /// Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write pub extern "C" fn InvoiceFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InvoiceFeaturesDecodeErrorZ { let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::InvoiceFeatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + 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() }; local_res }