+ crate::lightning::routing::scoring::MultiThreadedLockableScore { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
+
+use lightning::routing::scoring::ChannelUsage as nativeChannelUsageImport;
+pub(crate) type nativeChannelUsage = nativeChannelUsageImport;
+
+/// Proposed use of a channel passed as a parameter to [`Score::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 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) {
+ unsafe { let _ = 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
+ }
+}
+/// 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 *mut 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()
+}
+
+use lightning::routing::scoring::FixedPenaltyScorer as nativeFixedPenaltyScorerImport;
+pub(crate) type nativeFixedPenaltyScorer = nativeFixedPenaltyScorerImport;
+
+/// [`Score`] implementation that uses a fixed penalty.
+#[must_use]
+#[repr(C)]
+pub struct FixedPenaltyScorer {
+ /// 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 nativeFixedPenaltyScorer,
+ /// 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 Drop for FixedPenaltyScorer {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeFixedPenaltyScorer>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the FixedPenaltyScorer, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn FixedPenaltyScorer_free(this_obj: FixedPenaltyScorer) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn FixedPenaltyScorer_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFixedPenaltyScorer); }
+}
+#[allow(unused)]
+impl FixedPenaltyScorer {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeFixedPenaltyScorer {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFixedPenaltyScorer {
+ 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 nativeFixedPenaltyScorer {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for FixedPenaltyScorer {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeFixedPenaltyScorer>::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 FixedPenaltyScorer_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFixedPenaltyScorer)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the FixedPenaltyScorer
+pub extern "C" fn FixedPenaltyScorer_clone(orig: &FixedPenaltyScorer) -> FixedPenaltyScorer {
+ orig.clone()
+}
+/// Creates a new scorer using `penalty_msat`.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn FixedPenaltyScorer_with_penalty(mut penalty_msat: u64) -> crate::lightning::routing::scoring::FixedPenaltyScorer {
+ let mut ret = lightning::routing::scoring::FixedPenaltyScorer::with_penalty(penalty_msat);
+ crate::lightning::routing::scoring::FixedPenaltyScorer { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
+impl From<nativeFixedPenaltyScorer> for crate::lightning::routing::scoring::Score {
+ fn from(obj: nativeFixedPenaltyScorer) -> Self {
+ let mut rust_obj = FixedPenaltyScorer { inner: ObjOps::heap_alloc(obj), is_owned: true };
+ let mut ret = FixedPenaltyScorer_as_Score(&rust_obj);
+ // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
+ rust_obj.inner = core::ptr::null_mut();
+ ret.free = Some(FixedPenaltyScorer_free_void);
+ ret
+ }
+}
+/// Constructs a new Score which calls the relevant methods on this_arg.
+/// This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is
+#[no_mangle]
+pub extern "C" fn FixedPenaltyScorer_as_Score(this_arg: &FixedPenaltyScorer) -> crate::lightning::routing::scoring::Score {
+ crate::lightning::routing::scoring::Score {
+ this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+ free: None,
+ channel_penalty_msat: FixedPenaltyScorer_Score_channel_penalty_msat,
+ payment_path_failed: FixedPenaltyScorer_Score_payment_path_failed,
+ payment_path_successful: FixedPenaltyScorer_Score_payment_path_successful,
+ probe_failed: FixedPenaltyScorer_Score_probe_failed,
+ probe_successful: FixedPenaltyScorer_Score_probe_successful,
+ write: FixedPenaltyScorer_write_void,
+ }