[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / Sleeper.java
index 60bce88f5aec3cbce0e37e8ef3b73b4e98a1b1a8..189e2bb08afd6b8ca31213db7c9dc73d6c67f769 100644 (file)
@@ -25,7 +25,7 @@ public class Sleeper extends CommonBase {
         * Constructs a new sleeper from one future, allowing blocking on it.
         */
        public static Sleeper from_single_future(org.ldk.structs.Future future) {
-               long ret = bindings.Sleeper_from_single_future(future == null ? 0 : future.ptr);
+               long ret = bindings.Sleeper_from_single_future(future.ptr);
                Reference.reachabilityFence(future);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.Sleeper ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Sleeper(null, ret); }
@@ -38,7 +38,7 @@ public class Sleeper extends CommonBase {
         * Constructs a new sleeper from two futures, allowing blocking on both at once.
         */
        public static Sleeper from_two_futures(org.ldk.structs.Future fut_a, org.ldk.structs.Future fut_b) {
-               long ret = bindings.Sleeper_from_two_futures(fut_a == null ? 0 : fut_a.ptr, fut_b == null ? 0 : fut_b.ptr);
+               long ret = bindings.Sleeper_from_two_futures(fut_a.ptr, fut_b.ptr);
                Reference.reachabilityFence(fut_a);
                Reference.reachabilityFence(fut_b);
                if (ret >= 0 && ret <= 4096) { return null; }
@@ -53,12 +53,20 @@ public class Sleeper extends CommonBase {
         * Constructs a new sleeper on many futures, allowing blocking on all at once.
         */
        public static Sleeper of(Future[] futures) {
-               long ret = bindings.Sleeper_new(futures != null ? Arrays.stream(futures).mapToLong(futures_conv_8 -> futures_conv_8 == null ? 0 : futures_conv_8.ptr).toArray() : null);
+               long ret = bindings.Sleeper_new(futures != null ? Arrays.stream(futures).mapToLong(futures_conv_8 -> futures_conv_8.ptr).toArray() : null);
                Reference.reachabilityFence(futures);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.Sleeper ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Sleeper(null, ret); }
                if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
-               for (Future futures_conv_8: futures) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(futures_conv_8); }; };
+               for (Future futures_conv_8: futures) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(futures_conv_8); };
+               // Due to rust's strict-ownership memory model, in some cases we need to "move"
+               // an object to pass exclusive ownership to the function being called.
+               // In most cases, we avoid ret_hu_conv being visible in GC'd languages by cloning the object
+               // at the FFI layer, creating a new object which Rust can claim ownership of
+               // However, in some cases (eg here), there is no way to clone an object, and thus
+               // we actually have to pass full ownership to Rust.
+               // Thus, after ret_hu_conv call, futures_conv_8 is reset to null and is now a dummy object.
+               futures_conv_8.ptr = 0;; };
                return ret_hu_conv;
        }