+use lightning::routing::scoring::MultiThreadedScoreLockRead as nativeMultiThreadedScoreLockReadImport;
+pub(crate) type nativeMultiThreadedScoreLockRead = nativeMultiThreadedScoreLockReadImport<'static, crate::lightning::routing::scoring::Score, >;
+
+/// A locked `MultiThreadedLockableScore`.
+#[must_use]
+#[repr(C)]
+pub struct MultiThreadedScoreLockRead {
+ /// A pointer to the opaque Rust object.
+
+ /// 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 nativeMultiThreadedScoreLockRead,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl core::ops::Deref for MultiThreadedScoreLockRead {
+ type Target = nativeMultiThreadedScoreLockRead;
+ fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } }
+}
+unsafe impl core::marker::Send for MultiThreadedScoreLockRead { }
+unsafe impl core::marker::Sync for MultiThreadedScoreLockRead { }
+impl Drop for MultiThreadedScoreLockRead {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeMultiThreadedScoreLockRead>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the MultiThreadedScoreLockRead, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn MultiThreadedScoreLockRead_free(this_obj: MultiThreadedScoreLockRead) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn MultiThreadedScoreLockRead_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeMultiThreadedScoreLockRead) };
+}
+#[allow(unused)]
+impl MultiThreadedScoreLockRead {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeMultiThreadedScoreLockRead {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeMultiThreadedScoreLockRead {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeMultiThreadedScoreLockRead {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+ pub(crate) fn as_ref_to(&self) -> Self {
+ Self { inner: self.inner, is_owned: false }
+ }
+}
+
+use lightning::routing::scoring::MultiThreadedScoreLockWrite as nativeMultiThreadedScoreLockWriteImport;
+pub(crate) type nativeMultiThreadedScoreLockWrite = nativeMultiThreadedScoreLockWriteImport<'static, crate::lightning::routing::scoring::Score, >;
+
+/// A locked `MultiThreadedLockableScore`.
+#[must_use]
+#[repr(C)]
+pub struct MultiThreadedScoreLockWrite {
+ /// A pointer to the opaque Rust object.
+
+ /// 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 nativeMultiThreadedScoreLockWrite,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl core::ops::Deref for MultiThreadedScoreLockWrite {
+ type Target = nativeMultiThreadedScoreLockWrite;
+ fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } }
+}
+unsafe impl core::marker::Send for MultiThreadedScoreLockWrite { }
+unsafe impl core::marker::Sync for MultiThreadedScoreLockWrite { }
+impl Drop for MultiThreadedScoreLockWrite {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeMultiThreadedScoreLockWrite>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the MultiThreadedScoreLockWrite, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn MultiThreadedScoreLockWrite_free(this_obj: MultiThreadedScoreLockWrite) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn MultiThreadedScoreLockWrite_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeMultiThreadedScoreLockWrite) };
+}
+#[allow(unused)]
+impl MultiThreadedScoreLockWrite {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeMultiThreadedScoreLockWrite {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeMultiThreadedScoreLockWrite {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeMultiThreadedScoreLockWrite {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+ pub(crate) fn as_ref_to(&self) -> Self {
+ Self { inner: self.inner, is_owned: false }
+ }
+}
+impl From<nativeMultiThreadedScoreLockRead> for crate::lightning::routing::scoring::ScoreLookUp {
+ fn from(obj: nativeMultiThreadedScoreLockRead) -> Self {
+ let rust_obj = crate::lightning::routing::scoring::MultiThreadedScoreLockRead { inner: ObjOps::heap_alloc(obj), is_owned: true };
+ let mut ret = MultiThreadedScoreLockRead_as_ScoreLookUp(&rust_obj);
+ // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn
+ core::mem::forget(rust_obj);
+ ret.free = Some(MultiThreadedScoreLockRead_free_void);
+ ret
+ }
+}
+/// Constructs a new ScoreLookUp which calls the relevant methods on this_arg.
+/// This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is
+#[no_mangle]
+pub extern "C" fn MultiThreadedScoreLockRead_as_ScoreLookUp(this_arg: &MultiThreadedScoreLockRead) -> crate::lightning::routing::scoring::ScoreLookUp {
+ crate::lightning::routing::scoring::ScoreLookUp {
+ this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+ free: None,
+ channel_penalty_msat: MultiThreadedScoreLockRead_ScoreLookUp_channel_penalty_msat,
+ }
+}
+
+#[must_use]
+extern "C" fn MultiThreadedScoreLockRead_ScoreLookUp_channel_penalty_msat(this_arg: *const c_void, candidate: &crate::lightning::routing::router::CandidateRouteHop, mut usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 {
+ let mut ret = <nativeMultiThreadedScoreLockRead as lightning::routing::scoring::ScoreLookUp>::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockRead) }, &candidate.to_native(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref());
+ ret
+}
+
+#[no_mangle]
+/// Serialize the MultiThreadedScoreLockWrite object into a byte array which can be read by MultiThreadedScoreLockWrite_read
+pub extern "C" fn MultiThreadedScoreLockWrite_write(obj: &crate::lightning::routing::scoring::MultiThreadedScoreLockWrite) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[allow(unused)]
+pub(crate) extern "C" fn MultiThreadedScoreLockWrite_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::scoring::nativeMultiThreadedScoreLockWrite) })
+}
+impl From<nativeMultiThreadedScoreLockWrite> for crate::lightning::routing::scoring::ScoreUpdate {
+ fn from(obj: nativeMultiThreadedScoreLockWrite) -> Self {
+ let rust_obj = crate::lightning::routing::scoring::MultiThreadedScoreLockWrite { inner: ObjOps::heap_alloc(obj), is_owned: true };
+ let mut ret = MultiThreadedScoreLockWrite_as_ScoreUpdate(&rust_obj);
+ // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn
+ core::mem::forget(rust_obj);
+ ret.free = Some(MultiThreadedScoreLockWrite_free_void);
+ ret
+ }
+}
+/// Constructs a new ScoreUpdate which calls the relevant methods on this_arg.
+/// This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is
+#[no_mangle]
+pub extern "C" fn MultiThreadedScoreLockWrite_as_ScoreUpdate(this_arg: &MultiThreadedScoreLockWrite) -> crate::lightning::routing::scoring::ScoreUpdate {
+ crate::lightning::routing::scoring::ScoreUpdate {
+ this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+ free: None,
+ payment_path_failed: MultiThreadedScoreLockWrite_ScoreUpdate_payment_path_failed,
+ payment_path_successful: MultiThreadedScoreLockWrite_ScoreUpdate_payment_path_successful,
+ probe_failed: MultiThreadedScoreLockWrite_ScoreUpdate_probe_failed,
+ probe_successful: MultiThreadedScoreLockWrite_ScoreUpdate_probe_successful,
+ time_passed: MultiThreadedScoreLockWrite_ScoreUpdate_time_passed,
+ }
+}
+
+extern "C" fn MultiThreadedScoreLockWrite_ScoreUpdate_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: u64) {
+ <nativeMultiThreadedScoreLockWrite as lightning::routing::scoring::ScoreUpdate>::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockWrite) }, path.get_native_ref(), short_channel_id, core::time::Duration::from_secs(duration_since_epoch))
+}
+extern "C" fn MultiThreadedScoreLockWrite_ScoreUpdate_payment_path_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut duration_since_epoch: u64) {
+ <nativeMultiThreadedScoreLockWrite as lightning::routing::scoring::ScoreUpdate>::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockWrite) }, path.get_native_ref(), core::time::Duration::from_secs(duration_since_epoch))
+}
+extern "C" fn MultiThreadedScoreLockWrite_ScoreUpdate_probe_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: u64) {
+ <nativeMultiThreadedScoreLockWrite as lightning::routing::scoring::ScoreUpdate>::probe_failed(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockWrite) }, path.get_native_ref(), short_channel_id, core::time::Duration::from_secs(duration_since_epoch))
+}
+extern "C" fn MultiThreadedScoreLockWrite_ScoreUpdate_probe_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut duration_since_epoch: u64) {
+ <nativeMultiThreadedScoreLockWrite as lightning::routing::scoring::ScoreUpdate>::probe_successful(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockWrite) }, path.get_native_ref(), core::time::Duration::from_secs(duration_since_epoch))
+}
+extern "C" fn MultiThreadedScoreLockWrite_ScoreUpdate_time_passed(this_arg: *mut c_void, mut duration_since_epoch: u64) {
+ <nativeMultiThreadedScoreLockWrite as lightning::routing::scoring::ScoreUpdate>::time_passed(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockWrite) }, core::time::Duration::from_secs(duration_since_epoch))
+}
+
+
+use lightning::routing::scoring::ChannelUsage as nativeChannelUsageImport;
+pub(crate) type nativeChannelUsage = nativeChannelUsageImport;
+
+/// Proposed use of a channel passed as a parameter to [`ScoreLookUp::channel_penalty_msat`].
+#[must_use]
+#[repr(C)]
+pub struct ChannelUsage {
+ /// A pointer to the opaque Rust object.
+
+ /// 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 nativeChannelUsage,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl core::ops::Deref for ChannelUsage {
+ type Target = nativeChannelUsage;
+ fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } }
+}
+unsafe impl core::marker::Send for ChannelUsage { }
+unsafe impl core::marker::Sync for ChannelUsage { }
+impl Drop for ChannelUsage {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeChannelUsage>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the ChannelUsage, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn ChannelUsage_free(this_obj: ChannelUsage) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelUsage_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUsage) };
+}
+#[allow(unused)]
+impl ChannelUsage {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUsage {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUsage {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeChannelUsage {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+ pub(crate) fn as_ref_to(&self) -> Self {
+ Self { inner: self.inner, is_owned: false }
+ }
+}
+/// The amount to send through the channel, denominated in millisatoshis.
+#[no_mangle]
+pub extern "C" fn ChannelUsage_get_amount_msat(this_ptr: &ChannelUsage) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
+ *inner_val
+}
+/// The amount to send through the channel, denominated in millisatoshis.
+#[no_mangle]
+pub extern "C" fn ChannelUsage_set_amount_msat(this_ptr: &mut ChannelUsage, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
+}
+/// Total amount, denominated in millisatoshis, already allocated to send through the channel
+/// as part of a multi-path payment.
+#[no_mangle]
+pub extern "C" fn ChannelUsage_get_inflight_htlc_msat(this_ptr: &ChannelUsage) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().inflight_htlc_msat;
+ *inner_val
+}
+/// Total amount, denominated in millisatoshis, already allocated to send through the channel
+/// as part of a multi-path payment.
+#[no_mangle]
+pub extern "C" fn ChannelUsage_set_inflight_htlc_msat(this_ptr: &mut ChannelUsage, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inflight_htlc_msat = val;
+}
+/// The effective capacity of the channel.
+#[no_mangle]
+pub extern "C" fn ChannelUsage_get_effective_capacity(this_ptr: &ChannelUsage) -> crate::lightning::routing::gossip::EffectiveCapacity {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().effective_capacity;
+ crate::lightning::routing::gossip::EffectiveCapacity::from_native(inner_val)
+}
+/// The effective capacity of the channel.
+#[no_mangle]
+pub extern "C" fn ChannelUsage_set_effective_capacity(this_ptr: &mut ChannelUsage, mut val: crate::lightning::routing::gossip::EffectiveCapacity) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.effective_capacity = val.into_native();
+}
+/// Constructs a new ChannelUsage given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelUsage_new(mut amount_msat_arg: u64, mut inflight_htlc_msat_arg: u64, mut effective_capacity_arg: crate::lightning::routing::gossip::EffectiveCapacity) -> ChannelUsage {
+ ChannelUsage { inner: ObjOps::heap_alloc(nativeChannelUsage {
+ amount_msat: amount_msat_arg,
+ inflight_htlc_msat: inflight_htlc_msat_arg,
+ effective_capacity: effective_capacity_arg.into_native(),
+ }), is_owned: true }
+}
+impl Clone for ChannelUsage {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeChannelUsage>::is_null(self.inner) { core::ptr::null_mut() } else {
+ ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(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 ChannelUsage_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelUsage)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the ChannelUsage
+pub extern "C" fn ChannelUsage_clone(orig: &ChannelUsage) -> ChannelUsage {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a ChannelUsage object
+pub extern "C" fn ChannelUsage_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::scoring::ChannelUsage }).into()}
+