X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Futil%2Flogger.rs;fp=lightning-c-bindings%2Fsrc%2Flightning%2Futil%2Flogger.rs;h=eddadf6d9fe8a32d6ed30e6989f8d3b3f57fa234;hb=6658ad877ed253301df2c729b1c6a2a859515777;hp=037324543c1d56e6fb25352e7167eb63c049ed4f;hpb=7e6274489182ebb64202f790e462a9d464d75de2;p=ldk-c-bindings diff --git a/lightning-c-bindings/src/lightning/util/logger.rs b/lightning-c-bindings/src/lightning/util/logger.rs index 0373245..eddadf6 100644 --- a/lightning-c-bindings/src/lightning/util/logger.rs +++ b/lightning-c-bindings/src/lightning/util/logger.rs @@ -88,6 +88,21 @@ impl Level { pub extern "C" fn Level_clone(orig: &Level) -> Level { orig.clone() } +/// Checks if two Levels contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +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. +#[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 + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + std::hash::Hash::hash(&o.to_native(), &mut hasher); + std::hash::Hasher::finish(&hasher) +} /// Returns the most verbose logging level. #[must_use] #[no_mangle]