Update auto-generated bindings
[ldk-c-bindings] / lightning-c-bindings / src / lightning / util / errors.rs
index 8f0432685ee9f4cc9dd80ac8e490dcc884f0e1d3..fffe44fe462440b66338c7ccab1273ac68b3294b 100644 (file)
@@ -8,15 +8,18 @@
 
 //! Error types live here.
 
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
 
 /// Indicates an error on the client's part (usually some variant of attempting to use too-low or
 /// too-high values)
-#[must_use]
 #[derive(Clone)]
+#[must_use]
 #[repr(C)]
 pub enum APIError {
        /// Indicates the API was wholly misused (see err for more). Cases where these can be returned
@@ -63,7 +66,9 @@ pub enum APIError {
                script: crate::lightning::ln::script::ShutdownScript,
        },
 }
-use lightning::util::errors::APIError as nativeAPIError;
+use lightning::util::errors::APIError as APIErrorImport;
+pub(crate) type nativeAPIError = APIErrorImport;
+
 impl APIError {
        #[allow(unused)]
        pub(crate) fn to_native(&self) -> nativeAPIError {
@@ -168,7 +173,7 @@ impl APIError {
                        nativeAPIError::IncompatibleShutdownScript {ref script, } => {
                                let mut script_nonref = (*script).clone();
                                APIError::IncompatibleShutdownScript {
-                                       script: crate::lightning::ln::script::ShutdownScript { inner: Box::into_raw(Box::new(script_nonref)), is_owned: true },
+                                       script: crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(script_nonref), is_owned: true },
                                }
                        },
                }
@@ -200,7 +205,7 @@ impl APIError {
                        nativeAPIError::MonitorUpdateFailed => APIError::MonitorUpdateFailed,
                        nativeAPIError::IncompatibleShutdownScript {mut script, } => {
                                APIError::IncompatibleShutdownScript {
-                                       script: crate::lightning::ln::script::ShutdownScript { inner: Box::into_raw(Box::new(script)), is_owned: true },
+                                       script: crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(script), is_owned: true },
                                }
                        },
                }