Update auto-generated bindings to 0.0.106
[ldk-c-bindings] / lightning-c-bindings / src / lightning_persister.rs
index 303e73512dbcc7bab3f8bd2e5cf1dda1ed95436c..cd112e9c488cf3ad608750bcd897125d9a204eef 100644 (file)
@@ -8,19 +8,23 @@
 
 //! Utilities that handle persisting Rust-Lightning data to disk via standard filesystem APIs.
 
-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};
 
 mod util {
 
-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};
 
 }
 
@@ -81,7 +85,7 @@ impl FilesystemPersister {
        pub(crate) fn take_inner(mut self) -> *mut nativeFilesystemPersister {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -112,6 +116,16 @@ pub extern "C" fn FilesystemPersister_persist_manager(mut data_dir: crate::c_typ
        local_ret
 }
 
+/// Write the provided `NetworkGraph` to the path provided at `FilesystemPersister`
+/// initialization, within a file called \"network_graph\"
+#[must_use]
+#[no_mangle]
+pub extern "C" fn FilesystemPersister_persist_network_graph(mut data_dir: crate::c_types::Str, network_graph: &crate::lightning::routing::network_graph::NetworkGraph) -> crate::c_types::derived::CResult_NoneErrorZ {
+       let mut ret = lightning_persister::FilesystemPersister::persist_network_graph(data_dir.into_string(), network_graph.get_native_ref());
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_rust(e) }).into() };
+       local_ret
+}
+
 /// Read `ChannelMonitor`s from disk.
 #[must_use]
 #[no_mangle]
@@ -126,7 +140,7 @@ impl From<nativeFilesystemPersister> for crate::lightning::chain::chainmonitor::
                let mut rust_obj = FilesystemPersister { inner: ObjOps::heap_alloc(obj), is_owned: true };
                let mut ret = FilesystemPersister_as_Persist(&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(FilesystemPersister_free_void);
                ret
        }