7 namespace org { namespace ldk { namespace structs {
11 /** An implementation of FutureCallback */
12 public interface FutureCallbackInterface {
13 /**The method which is called.
19 * A callback which is called when a [`Future`] completes.
21 * Note that this MUST NOT call back into LDK directly, it must instead schedule actions to be
22 * taken later. Rust users should use the [`std::future::Future`] implementation for [`Future`]
25 * Note that the [`std::future::Future`] implementation may only work for runtimes which schedule
26 * futures when they receive a wake, rather than immediately executing them.
28 public class FutureCallback : CommonBase {
29 internal bindings.LDKFutureCallback bindings_instance;
30 internal long instance_idx;
32 internal FutureCallback(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
34 if (ptr != 0) { bindings.FutureCallback_free(ptr); }
37 private class LDKFutureCallbackHolder { internal FutureCallback held; }
38 private class LDKFutureCallbackImpl : bindings.LDKFutureCallback {
39 internal LDKFutureCallbackImpl(FutureCallbackInterface arg, LDKFutureCallbackHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
40 private FutureCallbackInterface arg;
41 private LDKFutureCallbackHolder impl_holder;
48 /** Creates a new instance of FutureCallback from a given implementation */
49 public static FutureCallback new_impl(FutureCallbackInterface arg) {
50 LDKFutureCallbackHolder impl_holder = new LDKFutureCallbackHolder();
51 LDKFutureCallbackImpl impl = new LDKFutureCallbackImpl(arg, impl_holder);
52 long[] ptr_idx = bindings.LDKFutureCallback_new(impl);
54 impl_holder.held = new FutureCallback(null, ptr_idx[0]);
55 impl_holder.held.instance_idx = ptr_idx[1];
56 impl_holder.held.bindings_instance = impl;
57 return impl_holder.held;
61 * The method which is called.
64 bindings.FutureCallback_call(this.ptr);