X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Futil%2Fser.rs;h=824dc7a06aae64973883bb22bb66e3b9c3068a0d;hb=11b997c3a0452ea1da5b7b352e7887798105db29;hp=23890d863974dff8669b0e8c21b6ac3f0323eed7;hpb=f10bdbea94cd8c638a42ab637a52e86a7cfd8157;p=ldk-c-bindings diff --git a/lightning-c-bindings/src/lightning/util/ser.rs b/lightning-c-bindings/src/lightning/util/ser.rs index 23890d8..824dc7a 100644 --- a/lightning-c-bindings/src/lightning/util/ser.rs +++ b/lightning-c-bindings/src/lightning/util/ser.rs @@ -7,7 +7,10 @@ // source was automatically generated. //! A very simple serialization framework which is used to serialize/deserialize messages as well -//! as ChannelsManagers and ChannelMonitors. +//! as [`ChannelManager`]s and [`ChannelMonitor`]s. +//! +//! [`ChannelManager`]: crate::ln::channelmanager::ChannelManager +//! [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor use alloc::str::FromStr; use core::ffi::c_void; @@ -25,7 +28,7 @@ pub static MAX_BUF_SIZE: usize = lightning::util::ser::MAX_BUF_SIZE; use lightning::util::ser::BigSize as nativeBigSizeImport; pub(crate) type nativeBigSize = nativeBigSizeImport; -/// Lightning TLV uses a custom variable-length integer called BigSize. It is similar to Bitcoin's +/// Lightning TLV uses a custom variable-length integer called `BigSize`. It is similar to Bitcoin's /// variable-length integers except that it is serialized in big-endian instead of little-endian. /// /// Like Bitcoin's variable-length integer, it exhibits ambiguity in that certain values can be @@ -60,7 +63,7 @@ pub extern "C" fn BigSize_free(this_obj: BigSize) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method pub(crate) extern "C" fn BigSize_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeBigSize); } + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBigSize) }; } #[allow(unused)] impl BigSize { @@ -103,7 +106,9 @@ pub(crate) type nativeHostname = nativeHostnameImport; /// Only the character set and length will be validated. /// The character set consists of ASCII alphanumeric characters, hyphens, and periods. /// Its length is guaranteed to be representable by a single byte. -/// This serialization is used by BOLT 7 hostnames. +/// This serialization is used by [`BOLT 7`] hostnames. +/// +/// [`BOLT 7`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md #[must_use] #[repr(C)] pub struct Hostname { @@ -132,7 +137,7 @@ pub extern "C" fn Hostname_free(this_obj: Hostname) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method pub(crate) extern "C" fn Hostname_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeHostname); } + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeHostname) }; } #[allow(unused)] impl Hostname { @@ -169,6 +174,15 @@ 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() } +/// 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. +#[no_mangle] +pub extern "C" fn Hostname_eq(a: &Hostname, b: &Hostname) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} /// Returns the length of the hostname. #[must_use] #[no_mangle]