1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
9 //! Structs and impls for receiving messages about the network and storing the topology live here.
11 use std::str::FromStr;
13 use core::convert::Infallible;
14 use bitcoin::hashes::Hash;
15 use crate::c_types::*;
17 pub mod network_graph;
20 /// An interface used to score payment channels for path finding.
22 ///\tScoring is in terms of fees willing to be paid in order to avoid routing through a channel.
25 /// An opaque pointer which is passed to your function implementations as an argument.
26 /// This has no meaning in the LDK, and can be NULL or any other value.
27 pub this_arg: *mut c_void,
28 /// Returns the fee in msats willing to be paid to avoid routing through the given channel.
30 pub channel_penalty_msat: extern "C" fn (this_arg: *const c_void, short_channel_id: u64) -> u64,
31 /// Frees any resources associated with this object given its this_arg pointer.
32 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
33 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
35 unsafe impl Send for Score {}
36 unsafe impl Sync for Score {}
38 pub(crate) extern "C" fn Score_clone_fields(orig: &Score) -> Score {
40 this_arg: orig.this_arg,
41 channel_penalty_msat: Clone::clone(&orig.channel_penalty_msat),
42 free: Clone::clone(&orig.free),
46 use lightning::routing::Score as rustScore;
47 impl rustScore for Score {
48 fn channel_penalty_msat(&self, mut short_channel_id: u64) -> u64 {
49 let mut ret = (self.channel_penalty_msat)(self.this_arg, short_channel_id);
54 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
55 // directly as a Deref trait in higher-level structs:
56 impl std::ops::Deref for Score {
58 fn deref(&self) -> &Self {
62 /// Calls the free function if one is set
64 pub extern "C" fn Score_free(this_ptr: Score) { }
67 if let Some(f) = self.free {