Update C/C++ demo tests with latest 0.0.121 API changes
[ldk-c-bindings] / lightning-c-bindings / src / lightning_rapid_gossip_sync / error.rs
index 808a81723ad9e2df0800442207b41ae0be05fd91..4b1b6ff8590c512e9691caee4bda4832e49df631 100644 (file)
@@ -9,6 +9,7 @@
 /// Error types that these functions can return
 
 use alloc::str::FromStr;
+use alloc::string::String;
 use core::ffi::c_void;
 use core::convert::Infallible;
 use bitcoin::hashes::Hash;
@@ -38,13 +39,13 @@ impl GraphSyncError {
        pub(crate) fn to_native(&self) -> nativeGraphSyncError {
                match self {
                        GraphSyncError::DecodeError (ref a, ) => {
-                               let mut a_nonref = (*a).clone();
+                               let mut a_nonref = Clone::clone(a);
                                nativeGraphSyncError::DecodeError (
-                                       *unsafe { Box::from_raw(a_nonref.take_inner()) },
+                                       a_nonref.into_native(),
                                )
                        },
                        GraphSyncError::LightningError (ref a, ) => {
-                               let mut a_nonref = (*a).clone();
+                               let mut a_nonref = Clone::clone(a);
                                nativeGraphSyncError::LightningError (
                                        *unsafe { Box::from_raw(a_nonref.take_inner()) },
                                )
@@ -56,7 +57,7 @@ impl GraphSyncError {
                match self {
                        GraphSyncError::DecodeError (mut a, ) => {
                                nativeGraphSyncError::DecodeError (
-                                       *unsafe { Box::from_raw(a.take_inner()) },
+                                       a.into_native(),
                                )
                        },
                        GraphSyncError::LightningError (mut a, ) => {
@@ -70,13 +71,13 @@ impl GraphSyncError {
        pub(crate) fn from_native(native: &nativeGraphSyncError) -> Self {
                match native {
                        nativeGraphSyncError::DecodeError (ref a, ) => {
-                               let mut a_nonref = (*a).clone();
+                               let mut a_nonref = Clone::clone(a);
                                GraphSyncError::DecodeError (
-                                       crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
+                                       crate::lightning::ln::msgs::DecodeError::native_into(a_nonref),
                                )
                        },
                        nativeGraphSyncError::LightningError (ref a, ) => {
-                               let mut a_nonref = (*a).clone();
+                               let mut a_nonref = Clone::clone(a);
                                GraphSyncError::LightningError (
                                        crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
                                )
@@ -88,7 +89,7 @@ impl GraphSyncError {
                match native {
                        nativeGraphSyncError::DecodeError (mut a, ) => {
                                GraphSyncError::DecodeError (
-                                       crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(a), is_owned: true },
+                                       crate::lightning::ln::msgs::DecodeError::native_into(a),
                                )
                        },
                        nativeGraphSyncError::LightningError (mut a, ) => {
@@ -107,6 +108,16 @@ pub extern "C" fn GraphSyncError_free(this_ptr: GraphSyncError) { }
 pub extern "C" fn GraphSyncError_clone(orig: &GraphSyncError) -> GraphSyncError {
        orig.clone()
 }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn GraphSyncError_clone_void(this_ptr: *const c_void) -> *mut c_void {
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *const GraphSyncError)).clone() })) as *mut c_void
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn GraphSyncError_free_void(this_ptr: *mut c_void) {
+       let _ = unsafe { Box::from_raw(this_ptr as *mut GraphSyncError) };
+}
 #[no_mangle]
 /// Utility method to constructs a new DecodeError-variant GraphSyncError
 pub extern "C" fn GraphSyncError_decode_error(a: crate::lightning::ln::msgs::DecodeError) -> GraphSyncError {