X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Futil%2Fser.rs;fp=lightning-c-bindings%2Fsrc%2Flightning%2Futil%2Fser.rs;h=6b5c46cf187f4d1da5a22d771b49c5093754b326;hp=eab63e57e2f3252b6453a4722798924d5b063158;hb=0ac4dbdb8352c898100b34f0ef8ed9cebfea7786;hpb=c16401631dddadcefa37b05074ca7def51b85af4 diff --git a/lightning-c-bindings/src/lightning/util/ser.rs b/lightning-c-bindings/src/lightning/util/ser.rs index eab63e5..6b5c46c 100644 --- a/lightning-c-bindings/src/lightning/util/ser.rs +++ b/lightning-c-bindings/src/lightning/util/ser.rs @@ -118,6 +118,9 @@ pub(crate) extern "C" fn BigSize_clone_void(this_ptr: *const c_void) -> *mut c_v pub extern "C" fn BigSize_clone(orig: &BigSize) -> BigSize { orig.clone() } +/// Get a string which allows debug introspection of a BigSize object +pub extern "C" fn BigSize_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::util::ser::BigSize }).into()} /// Generates a non-cryptographic 64-bit hash of the BigSize. #[no_mangle] pub extern "C" fn BigSize_hash(o: &BigSize) -> u64 { @@ -229,6 +232,19 @@ pub(crate) extern "C" fn Hostname_clone_void(this_ptr: *const c_void) -> *mut c_ pub extern "C" fn Hostname_clone(orig: &Hostname) -> Hostname { orig.clone() } +/// Get a string which allows debug introspection of a Hostname object +pub extern "C" fn Hostname_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::util::ser::Hostname }).into()} +/// Generates a non-cryptographic 64-bit hash of the Hostname. +#[no_mangle] +pub extern "C" fn Hostname_hash(o: &Hostname) -> u64 { + if o.inner.is_null() { return 0; } + // 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(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} /// Checks if two Hostnames contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. /// Two objects with NULL inner values will be considered "equal" here. @@ -335,6 +351,19 @@ pub(crate) extern "C" fn TransactionU16LenLimited_clone_void(this_ptr: *const c_ pub extern "C" fn TransactionU16LenLimited_clone(orig: &TransactionU16LenLimited) -> TransactionU16LenLimited { orig.clone() } +/// Get a string which allows debug introspection of a TransactionU16LenLimited object +pub extern "C" fn TransactionU16LenLimited_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::util::ser::TransactionU16LenLimited }).into()} +/// Generates a non-cryptographic 64-bit hash of the TransactionU16LenLimited. +#[no_mangle] +pub extern "C" fn TransactionU16LenLimited_hash(o: &TransactionU16LenLimited) -> u64 { + if o.inner.is_null() { return 0; } + // 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(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} /// Checks if two TransactionU16LenLimiteds contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. /// Two objects with NULL inner values will be considered "equal" here.