+/// Refers to a scorer that is accessible under lock and also writeable to disk
+///
+/// We need this trait to be able to pass in a scorer to `lightning-background-processor` that will enable us to
+/// use the Persister to persist it.
+#[repr(C)]
+pub struct WriteableScore {
+ /// An opaque pointer which is passed to your function implementations as an argument.
+ /// This has no meaning in the LDK, and can be NULL or any other value.
+ pub this_arg: *mut c_void,
+ /// Implementation of LockableScore for this object.
+ pub LockableScore: crate::lightning::routing::scoring::LockableScore,
+ /// Serialize the object into a byte array
+ pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z,
+ /// Frees any resources associated with this object given its this_arg pointer.
+ /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for WriteableScore {}
+unsafe impl Sync for WriteableScore {}
+#[no_mangle]
+pub(crate) extern "C" fn WriteableScore_clone_fields(orig: &WriteableScore) -> WriteableScore {
+ WriteableScore {
+ this_arg: orig.this_arg,
+ LockableScore: crate::lightning::routing::scoring::LockableScore_clone_fields(&orig.LockableScore),
+ write: Clone::clone(&orig.write),
+ free: Clone::clone(&orig.free),
+ }
+}
+impl<'a> lightning::routing::scoring::LockableScore<'a> for WriteableScore {
+ type Locked = crate::lightning::routing::scoring::Score;
+ fn lock(&'a self) -> crate::lightning::routing::scoring::Score {
+ let mut ret = (self.LockableScore.lock)(self.LockableScore.this_arg);
+ ret
+ }
+}
+impl lightning::util::ser::Writeable for WriteableScore {
+ fn write<W: lightning::util::ser::Writer>(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> {
+ let vec = (self.write)(self.this_arg);
+ w.write_all(vec.as_slice())
+ }
+}
+
+use lightning::routing::scoring::WriteableScore as rustWriteableScore;
+impl<'a> rustWriteableScore<'a> for WriteableScore {
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl core::ops::Deref for WriteableScore {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn WriteableScore_free(this_ptr: WriteableScore) { }
+impl Drop for WriteableScore {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}