-
-/// Creates a "default" Scorer. See struct and individual field documentaiton for details on which values are used.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn Scorer_default() -> Scorer {
- Scorer { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
-}
-/// Creates a "default" ScoringParameters. See struct and individual field documentaiton for details on which values are used.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn ScoringParameters_default() -> ScoringParameters {
- ScoringParameters { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
-}
-impl From<nativeScorer> for crate::lightning::routing::scoring::Score {
- fn from(obj: nativeScorer) -> Self {
- let mut rust_obj = Scorer { inner: ObjOps::heap_alloc(obj), is_owned: true };
- let mut ret = Scorer_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(Scorer_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 Scorer_as_Score(this_arg: &Scorer) -> 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: Scorer_Score_channel_penalty_msat,
- payment_path_failed: Scorer_Score_payment_path_failed,
- payment_path_successful: Scorer_Score_payment_path_successful,
- write: Scorer_write_void,
- }
-}
-
-#[must_use]
-extern "C" fn Scorer_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, mut send_amt_msat: u64, mut capacity_msat: u64, _source: &crate::lightning::routing::network_graph::NodeId, _target: &crate::lightning::routing::network_graph::NodeId) -> u64 {
- let mut ret = <nativeScorer as lightning::routing::scoring::Score<>>::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeScorer) }, short_channel_id, send_amt_msat, capacity_msat, _source.get_native_ref(), _target.get_native_ref());
- ret
-}
-extern "C" fn Scorer_Score_payment_path_failed(this_arg: *mut c_void, mut _path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) {
- let mut local__path = Vec::new(); for mut item in _path.as_slice().iter() { local__path.push( { item.get_native_ref() }); };
- <nativeScorer as lightning::routing::scoring::Score<>>::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeScorer) }, &local__path[..], short_channel_id)
-}
-extern "C" fn Scorer_Score_payment_path_successful(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) {
- let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); };
- <nativeScorer as lightning::routing::scoring::Score<>>::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeScorer) }, &local_path[..])
-}
-
-#[no_mangle]
-/// Serialize the Scorer object into a byte array which can be read by Scorer_read
-pub extern "C" fn Scorer_write(obj: &Scorer) -> crate::c_types::derived::CVec_u8Z {
- crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
-}
-#[no_mangle]
-pub(crate) extern "C" fn Scorer_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
- crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeScorer) })
-}
-#[no_mangle]
-/// Read a Scorer from a byte array, created by Scorer_write
-pub extern "C" fn Scorer_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ScorerDecodeErrorZ {
- let res: Result<lightning::routing::scoring::Scorer, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
- let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::scoring::Scorer { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
- local_res
-}
-
-use lightning::routing::scoring::ProbabilisticScoringParameters as nativeProbabilisticScoringParametersImport;
-pub(crate) type nativeProbabilisticScoringParameters = nativeProbabilisticScoringParametersImport;
-
-/// Parameters for configuring [`ProbabilisticScorer`].
-#[must_use]
-#[repr(C)]
-pub struct ProbabilisticScoringParameters {
- /// 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 nativeProbabilisticScoringParameters,
- /// 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 ProbabilisticScoringParameters {
- fn drop(&mut self) {
- if self.is_owned && !<*mut nativeProbabilisticScoringParameters>::is_null(self.inner) {
- let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
- }
- }
-}
-/// Frees any resources used by the ProbabilisticScoringParameters, if is_owned is set and inner is non-NULL.
-#[no_mangle]
-pub extern "C" fn ProbabilisticScoringParameters_free(this_obj: ProbabilisticScoringParameters) { }
-#[allow(unused)]
-/// Used only if an object of this type is returned as a trait impl by a method
-pub(crate) extern "C" fn ProbabilisticScoringParameters_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativeProbabilisticScoringParameters); }
-}
-#[allow(unused)]
-impl ProbabilisticScoringParameters {
- pub(crate) fn get_native_ref(&self) -> &'static nativeProbabilisticScoringParameters {
- unsafe { &*ObjOps::untweak_ptr(self.inner) }
- }
- pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeProbabilisticScoringParameters {
- 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 nativeProbabilisticScoringParameters {
- assert!(self.is_owned);
- let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = core::ptr::null_mut();
- ret
- }
-}
-/// A multiplier used to determine the amount in msats willing to be paid to avoid routing
-/// through a channel, as per multiplying by the negative `log10` of the channel's success
-/// probability for a payment.