Update auto-generated bindings
[ldk-c-bindings] / lightning-c-bindings / src / lightning_invoice / utils.rs
index ef8b51fe65bb30ea8117fd91706aaa1eb1f20741..79281aa889b55f9d84d028e61c832b284d773118 100644 (file)
@@ -8,11 +8,13 @@
 
 //! Convenient utilities to create an invoice.
 
-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};
 
 /// Utility to construct an invoice. Generally, unless you want to do something like a custom
 /// cltv_expiry, this is what you should be using to create an invoice. The reason being, this
@@ -74,7 +76,7 @@ impl DefaultRouter {
        pub(crate) fn take_inner(mut self) -> *mut nativeDefaultRouter {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -91,7 +93,7 @@ impl From<nativeDefaultRouter> for crate::lightning_invoice::payment::Router {
                let mut rust_obj = DefaultRouter { inner: ObjOps::heap_alloc(obj), is_owned: true };
                let mut ret = DefaultRouter_as_Router(&rust_obj);
                // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
-               rust_obj.inner = std::ptr::null_mut();
+               rust_obj.inner = core::ptr::null_mut();
                ret.free = Some(DefaultRouter_free_void);
                ret
        }
@@ -109,7 +111,7 @@ pub extern "C" fn DefaultRouter_as_Router(this_arg: &DefaultRouter) -> crate::li
 
 #[must_use]
 extern "C" fn DefaultRouter_Router_find_route(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, params: &crate::lightning::routing::router::RouteParameters, _payment_hash: *const [u8; 32], first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, scorer: &crate::lightning::routing::scoring::Score) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
-       let mut local_first_hops_base = if first_hops == std::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]);
+       let mut local_first_hops_base = if first_hops == core::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]);
        let mut ret = <nativeDefaultRouter as lightning_invoice::payment::Router<_>>::find_route(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), params.get_native_ref(), &::lightning::ln::PaymentHash(unsafe { *_payment_hash }), local_first_hops, scorer);
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
        local_ret
@@ -123,7 +125,7 @@ impl From<nativeChannelManager> for crate::lightning_invoice::payment::Payer {
                let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
                let mut ret = ChannelManager_as_Payer(&rust_obj);
                // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
-               rust_obj.inner = std::ptr::null_mut();
+               rust_obj.inner = core::ptr::null_mut();
                ret.free = Some(ChannelManager_free_void);
                ret
        }