]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add `WriteableScore` bindings impl for `MultiThreadedLockableScore` 2022-09-111-java-bindings
authorMatt Corallo <git@bluematt.me>
Thu, 29 Sep 2022 15:22:47 +0000 (15:22 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 6 Oct 2022 17:41:05 +0000 (17:41 +0000)
In 56b07e52aabdaca521987e765f1fa864966a5d49 we made
`MultiThreadedLockableScore` fully bindings-compatible. However, it
did not add a `WriteableScore` implementation for it. This was an
oversight as it is a `WriteableScore` in Rust and needs to be for
use in other parts of the API.

Here we add the required impl in a way that the bindings generator
is able to handle it and add conversion utilities.

lightning/src/routing/scoring.rs

index ad0852b08d9efdb61989fb11b17419e491755c5c..6128057791dea6192958e75f861bf555b461fe3b 100644 (file)
@@ -224,6 +224,16 @@ impl<'a, T: Score + 'a> LockableScore<'a> for MultiThreadedLockableScore<T> {
        }
 }
 
+#[cfg(c_bindings)]
+impl<T: Score> Writeable for MultiThreadedLockableScore<T> {
+       fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
+               self.lock().write(writer)
+       }
+}
+
+#[cfg(c_bindings)]
+impl<'a, T: Score + 'a> WriteableScore<'a> for MultiThreadedLockableScore<T> {}
+
 #[cfg(c_bindings)]
 impl<T: Score> MultiThreadedLockableScore<T> {
        /// Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`].