Update auto-generated bindings to LDK 0.0.118
[ldk-c-bindings] / lightning-c-bindings / src / lightning / util / logger.rs
index 7d0e7953f9d987f6df7ae252f28f0414cd85b936..645fafa555659b201762d1c52aeb2c6c4e9a07a3 100644 (file)
 //! The second one, client-side by implementing check against Record Level field.
 //! Each module may have its own Logger or share one.
 
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use alloc::string::String;
+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};
 
 /// An enum representing the available verbosity levels of the logger.
-#[must_use]
 #[derive(Clone)]
+#[must_use]
 #[repr(C)]
 pub enum Level {
        /// Designates extremely verbose information, including gossip-induced messages
@@ -37,7 +40,9 @@ pub enum Level {
        /// Designates very serious errors
        Error,
 }
-use lightning::util::logger::Level as nativeLevel;
+use lightning::util::logger::Level as LevelImport;
+pub(crate) type nativeLevel = LevelImport;
+
 impl Level {
        #[allow(unused)]
        pub(crate) fn to_native(&self) -> nativeLevel {
@@ -89,6 +94,16 @@ impl Level {
 pub extern "C" fn Level_clone(orig: &Level) -> Level {
        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 Level_clone_void(this_ptr: *const c_void) -> *mut c_void {
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Level)).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 Level_free_void(this_ptr: *mut c_void) {
+       let _ = unsafe { Box::from_raw(this_ptr as *mut Level) };
+}
 #[no_mangle]
 /// Utility method to constructs a new Gossip-variant Level
 pub extern "C" fn Level_gossip() -> Level {
@@ -119,14 +134,14 @@ pub extern "C" fn Level_error() -> Level {
 pub extern "C" fn Level_eq(a: &Level, b: &Level) -> bool {
        if &a.to_native() == &b.to_native() { true } else { false }
 }
-/// Checks if two Levels contain equal inner contents.
+/// Generates a non-cryptographic 64-bit hash of the Level.
 #[no_mangle]
 pub extern "C" fn Level_hash(o: &Level) -> u64 {
-       // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+       // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
        #[allow(deprecated)]
        let mut hasher = core::hash::SipHasher::new();
-       std::hash::Hash::hash(&o.to_native(), &mut hasher);
-       std::hash::Hasher::finish(&hasher)
+       core::hash::Hash::hash(&o.to_native(), &mut hasher);
+       core::hash::Hasher::finish(&hasher)
 }
 /// Returns the most verbose logging level.
 #[must_use]
@@ -170,7 +185,7 @@ pub extern "C" fn Record_free(this_obj: Record) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
 pub(crate) extern "C" fn Record_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRecord); }
+       let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRecord) };
 }
 #[allow(unused)]
 impl Record {
@@ -184,7 +199,7 @@ impl Record {
        pub(crate) fn take_inner(mut self) -> *mut nativeRecord {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -246,7 +261,7 @@ pub extern "C" fn Record_set_line(this_ptr: &mut Record, mut val: u32) {
 impl Clone for Record {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeRecord>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeRecord>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }
@@ -255,7 +270,7 @@ impl Clone for Record {
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
 pub(crate) extern "C" fn Record_clone_void(this_ptr: *const c_void) -> *mut c_void {
-       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRecord)).clone() })) as *mut c_void
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRecord)).clone() })) as *mut c_void
 }
 #[no_mangle]
 /// Creates a copy of the Record
@@ -276,8 +291,8 @@ pub struct Logger {
 }
 unsafe impl Send for Logger {}
 unsafe impl Sync for Logger {}
-#[no_mangle]
-pub(crate) extern "C" fn Logger_clone_fields(orig: &Logger) -> Logger {
+#[allow(unused)]
+pub(crate) fn Logger_clone_fields(orig: &Logger) -> Logger {
        Logger {
                this_arg: orig.this_arg,
                log: Clone::clone(&orig.log),
@@ -294,12 +309,17 @@ impl rustLogger for Logger {
 
 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
 // directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for Logger {
+impl core::ops::Deref for Logger {
        type Target = Self;
        fn deref(&self) -> &Self {
                self
        }
 }
+impl core::ops::DerefMut for Logger {
+       fn deref_mut(&mut self) -> &mut Self {
+               self
+       }
+}
 /// Calls the free function if one is set
 #[no_mangle]
 pub extern "C" fn Logger_free(this_ptr: Logger) { }