Auto-generated bindings updates
[rust-lightning] / lightning-c-bindings / src / util / config.rs
index 53a7d940248953725d128faf78a901551a46fab3..9f8769d80231eda8b1dede261d1e99c7f436d18c 100644 (file)
@@ -15,7 +15,7 @@ type nativeChannelHandshakeConfig = nativeChannelHandshakeConfigImport;
 #[must_use]
 #[repr(C)]
 pub struct ChannelHandshakeConfig {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeChannelHandshakeConfig,
        pub is_owned: bool,
@@ -23,7 +23,7 @@ pub struct ChannelHandshakeConfig {
 
 impl Drop for ChannelHandshakeConfig {
        fn drop(&mut self) {
-               if self.is_owned && !self.inner.is_null() {
+               if self.is_owned && !<*mut nativeChannelHandshakeConfig>::is_null(self.inner) {
                        let _ = unsafe { Box::from_raw(self.inner) };
                }
        }
@@ -38,26 +38,13 @@ extern "C" fn ChannelHandshakeConfig_free_void(this_ptr: *mut c_void) {
 #[allow(unused)]
 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
 impl ChannelHandshakeConfig {
-       pub(crate) fn take_ptr(mut self) -> *mut nativeChannelHandshakeConfig {
+       pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeConfig {
                assert!(self.is_owned);
                let ret = self.inner;
                self.inner = std::ptr::null_mut();
                ret
        }
 }
-impl Clone for ChannelHandshakeConfig {
-       fn clone(&self) -> Self {
-               Self {
-                       inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
-                       is_owned: true,
-               }
-       }
-}
-#[allow(unused)]
-/// Used only if an object of this type is returned as a trait impl by a method
-pub(crate) extern "C" fn ChannelHandshakeConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
-       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeConfig)).clone() })) as *mut c_void
-}
 /// Confirmations we will wait for before considering the channel locked in.
 /// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
 /// equivalent limit applied to outbound channels).
@@ -142,6 +129,24 @@ pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our
                our_htlc_minimum_msat: our_htlc_minimum_msat_arg,
        })), is_owned: true }
 }
+impl Clone for ChannelHandshakeConfig {
+       fn clone(&self) -> Self {
+               Self {
+                       inner: if <*mut nativeChannelHandshakeConfig>::is_null(self.inner) { std::ptr::null_mut() } else {
+                               Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
+                       is_owned: true,
+               }
+       }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelHandshakeConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeConfig)).clone() })) as *mut c_void
+}
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_clone(orig: &ChannelHandshakeConfig) -> ChannelHandshakeConfig {
+       orig.clone()
+}
 #[must_use]
 #[no_mangle]
 pub extern "C" fn ChannelHandshakeConfig_default() -> ChannelHandshakeConfig {
@@ -165,7 +170,7 @@ type nativeChannelHandshakeLimits = nativeChannelHandshakeLimitsImport;
 #[must_use]
 #[repr(C)]
 pub struct ChannelHandshakeLimits {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeChannelHandshakeLimits,
        pub is_owned: bool,
@@ -173,7 +178,7 @@ pub struct ChannelHandshakeLimits {
 
 impl Drop for ChannelHandshakeLimits {
        fn drop(&mut self) {
-               if self.is_owned && !self.inner.is_null() {
+               if self.is_owned && !<*mut nativeChannelHandshakeLimits>::is_null(self.inner) {
                        let _ = unsafe { Box::from_raw(self.inner) };
                }
        }
@@ -188,26 +193,13 @@ extern "C" fn ChannelHandshakeLimits_free_void(this_ptr: *mut c_void) {
 #[allow(unused)]
 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
 impl ChannelHandshakeLimits {
-       pub(crate) fn take_ptr(mut self) -> *mut nativeChannelHandshakeLimits {
+       pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeLimits {
                assert!(self.is_owned);
                let ret = self.inner;
                self.inner = std::ptr::null_mut();
                ret
        }
 }
-impl Clone for ChannelHandshakeLimits {
-       fn clone(&self) -> Self {
-               Self {
-                       inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
-                       is_owned: true,
-               }
-       }
-}
-#[allow(unused)]
-/// Used only if an object of this type is returned as a trait impl by a method
-pub(crate) extern "C" fn ChannelHandshakeLimits_clone_void(this_ptr: *const c_void) -> *mut c_void {
-       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeLimits)).clone() })) as *mut c_void
-}
 /// Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
 /// only applies to inbound channels.
 ///
@@ -420,6 +412,24 @@ pub extern "C" fn ChannelHandshakeLimits_new(mut min_funding_satoshis_arg: u64,
                their_to_self_delay: their_to_self_delay_arg,
        })), is_owned: true }
 }
+impl Clone for ChannelHandshakeLimits {
+       fn clone(&self) -> Self {
+               Self {
+                       inner: if <*mut nativeChannelHandshakeLimits>::is_null(self.inner) { std::ptr::null_mut() } else {
+                               Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
+                       is_owned: true,
+               }
+       }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelHandshakeLimits_clone_void(this_ptr: *const c_void) -> *mut c_void {
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeLimits)).clone() })) as *mut c_void
+}
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_clone(orig: &ChannelHandshakeLimits) -> ChannelHandshakeLimits {
+       orig.clone()
+}
 #[must_use]
 #[no_mangle]
 pub extern "C" fn ChannelHandshakeLimits_default() -> ChannelHandshakeLimits {
@@ -434,7 +444,7 @@ type nativeChannelConfig = nativeChannelConfigImport;
 #[must_use]
 #[repr(C)]
 pub struct ChannelConfig {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeChannelConfig,
        pub is_owned: bool,
@@ -442,7 +452,7 @@ pub struct ChannelConfig {
 
 impl Drop for ChannelConfig {
        fn drop(&mut self) {
-               if self.is_owned && !self.inner.is_null() {
+               if self.is_owned && !<*mut nativeChannelConfig>::is_null(self.inner) {
                        let _ = unsafe { Box::from_raw(self.inner) };
                }
        }
@@ -457,26 +467,13 @@ extern "C" fn ChannelConfig_free_void(this_ptr: *mut c_void) {
 #[allow(unused)]
 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
 impl ChannelConfig {
-       pub(crate) fn take_ptr(mut self) -> *mut nativeChannelConfig {
+       pub(crate) fn take_inner(mut self) -> *mut nativeChannelConfig {
                assert!(self.is_owned);
                let ret = self.inner;
                self.inner = std::ptr::null_mut();
                ret
        }
 }
-impl Clone for ChannelConfig {
-       fn clone(&self) -> Self {
-               Self {
-                       inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
-                       is_owned: true,
-               }
-       }
-}
-#[allow(unused)]
-/// Used only if an object of this type is returned as a trait impl by a method
-pub(crate) extern "C" fn ChannelConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
-       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelConfig)).clone() })) as *mut c_void
-}
 /// Amount (in millionths of a satoshi) the channel will charge per transferred satoshi.
 /// This may be allowed to change at runtime in a later update, however doing so must result in
 /// update messages sent to notify all nodes of our updated relay fee.
@@ -567,22 +564,42 @@ pub extern "C" fn ChannelConfig_new(mut fee_proportional_millionths_arg: u32, mu
                commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg,
        })), is_owned: true }
 }
+impl Clone for ChannelConfig {
+       fn clone(&self) -> Self {
+               Self {
+                       inner: if <*mut nativeChannelConfig>::is_null(self.inner) { std::ptr::null_mut() } else {
+                               Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
+                       is_owned: true,
+               }
+       }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelConfig)).clone() })) as *mut c_void
+}
+#[no_mangle]
+pub extern "C" fn ChannelConfig_clone(orig: &ChannelConfig) -> ChannelConfig {
+       orig.clone()
+}
 #[must_use]
 #[no_mangle]
 pub extern "C" fn ChannelConfig_default() -> ChannelConfig {
        ChannelConfig { inner: Box::into_raw(Box::new(Default::default())), is_owned: true }
 }
 #[no_mangle]
-pub extern "C" fn ChannelConfig_write(obj: *const ChannelConfig) -> crate::c_types::derived::CVec_u8Z {
-       crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+pub extern "C" fn ChannelConfig_write(obj: &ChannelConfig) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
 }
 #[no_mangle]
-pub extern "C" fn ChannelConfig_read(ser: crate::c_types::u8slice) -> ChannelConfig {
-       if let Ok(res) = crate::c_types::deserialize_obj(ser) {
-               ChannelConfig { inner: Box::into_raw(Box::new(res)), is_owned: true }
-       } else {
-               ChannelConfig { inner: std::ptr::null_mut(), is_owned: true }
-       }
+pub(crate) extern "C" fn ChannelConfig_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelConfig) })
+}
+#[no_mangle]
+pub extern "C" fn ChannelConfig_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelConfigDecodeErrorZ {
+       let res = crate::c_types::deserialize_obj(ser);
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::util::config::ChannelConfig { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
+       local_res
 }
 
 use lightning::util::config::UserConfig as nativeUserConfigImport;
@@ -595,7 +612,7 @@ type nativeUserConfig = nativeUserConfigImport;
 #[must_use]
 #[repr(C)]
 pub struct UserConfig {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeUserConfig,
        pub is_owned: bool,
@@ -603,7 +620,7 @@ pub struct UserConfig {
 
 impl Drop for UserConfig {
        fn drop(&mut self) {
-               if self.is_owned && !self.inner.is_null() {
+               if self.is_owned && !<*mut nativeUserConfig>::is_null(self.inner) {
                        let _ = unsafe { Box::from_raw(self.inner) };
                }
        }
@@ -618,26 +635,13 @@ extern "C" fn UserConfig_free_void(this_ptr: *mut c_void) {
 #[allow(unused)]
 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
 impl UserConfig {
-       pub(crate) fn take_ptr(mut self) -> *mut nativeUserConfig {
+       pub(crate) fn take_inner(mut self) -> *mut nativeUserConfig {
                assert!(self.is_owned);
                let ret = self.inner;
                self.inner = std::ptr::null_mut();
                ret
        }
 }
-impl Clone for UserConfig {
-       fn clone(&self) -> Self {
-               Self {
-                       inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
-                       is_owned: true,
-               }
-       }
-}
-#[allow(unused)]
-/// Used only if an object of this type is returned as a trait impl by a method
-pub(crate) extern "C" fn UserConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
-       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUserConfig)).clone() })) as *mut c_void
-}
 /// Channel config that we propose to our counterparty.
 #[no_mangle]
 pub extern "C" fn UserConfig_get_own_channel_config(this_ptr: &UserConfig) -> crate::util::config::ChannelHandshakeConfig {
@@ -647,7 +651,7 @@ pub extern "C" fn UserConfig_get_own_channel_config(this_ptr: &UserConfig) -> cr
 /// Channel config that we propose to our counterparty.
 #[no_mangle]
 pub extern "C" fn UserConfig_set_own_channel_config(this_ptr: &mut UserConfig, mut val: crate::util::config::ChannelHandshakeConfig) {
-       unsafe { &mut *this_ptr.inner }.own_channel_config = *unsafe { Box::from_raw(val.take_ptr()) };
+       unsafe { &mut *this_ptr.inner }.own_channel_config = *unsafe { Box::from_raw(val.take_inner()) };
 }
 /// Limits applied to our counterparty's proposed channel config settings.
 #[no_mangle]
@@ -658,7 +662,7 @@ pub extern "C" fn UserConfig_get_peer_channel_config_limits(this_ptr: &UserConfi
 /// Limits applied to our counterparty's proposed channel config settings.
 #[no_mangle]
 pub extern "C" fn UserConfig_set_peer_channel_config_limits(this_ptr: &mut UserConfig, mut val: crate::util::config::ChannelHandshakeLimits) {
-       unsafe { &mut *this_ptr.inner }.peer_channel_config_limits = *unsafe { Box::from_raw(val.take_ptr()) };
+       unsafe { &mut *this_ptr.inner }.peer_channel_config_limits = *unsafe { Box::from_raw(val.take_inner()) };
 }
 /// Channel config which affects behavior during channel lifetime.
 #[no_mangle]
@@ -669,17 +673,35 @@ pub extern "C" fn UserConfig_get_channel_options(this_ptr: &UserConfig) -> crate
 /// Channel config which affects behavior during channel lifetime.
 #[no_mangle]
 pub extern "C" fn UserConfig_set_channel_options(this_ptr: &mut UserConfig, mut val: crate::util::config::ChannelConfig) {
-       unsafe { &mut *this_ptr.inner }.channel_options = *unsafe { Box::from_raw(val.take_ptr()) };
+       unsafe { &mut *this_ptr.inner }.channel_options = *unsafe { Box::from_raw(val.take_inner()) };
 }
 #[must_use]
 #[no_mangle]
 pub extern "C" fn UserConfig_new(mut own_channel_config_arg: crate::util::config::ChannelHandshakeConfig, mut peer_channel_config_limits_arg: crate::util::config::ChannelHandshakeLimits, mut channel_options_arg: crate::util::config::ChannelConfig) -> UserConfig {
        UserConfig { inner: Box::into_raw(Box::new(nativeUserConfig {
-               own_channel_config: *unsafe { Box::from_raw(own_channel_config_arg.take_ptr()) },
-               peer_channel_config_limits: *unsafe { Box::from_raw(peer_channel_config_limits_arg.take_ptr()) },
-               channel_options: *unsafe { Box::from_raw(channel_options_arg.take_ptr()) },
+               own_channel_config: *unsafe { Box::from_raw(own_channel_config_arg.take_inner()) },
+               peer_channel_config_limits: *unsafe { Box::from_raw(peer_channel_config_limits_arg.take_inner()) },
+               channel_options: *unsafe { Box::from_raw(channel_options_arg.take_inner()) },
        })), is_owned: true }
 }
+impl Clone for UserConfig {
+       fn clone(&self) -> Self {
+               Self {
+                       inner: if <*mut nativeUserConfig>::is_null(self.inner) { std::ptr::null_mut() } else {
+                               Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
+                       is_owned: true,
+               }
+       }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn UserConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUserConfig)).clone() })) as *mut c_void
+}
+#[no_mangle]
+pub extern "C" fn UserConfig_clone(orig: &UserConfig) -> UserConfig {
+       orig.clone()
+}
 #[must_use]
 #[no_mangle]
 pub extern "C" fn UserConfig_default() -> UserConfig {