[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / FutureCallback.cs
1
2 using org.ldk.impl;
3 using org.ldk.enums;
4 using org.ldk.util;
5 using System;
6
7 namespace org { namespace ldk { namespace structs {
8
9
10
11 /** An implementation of FutureCallback */
12 public interface FutureCallbackInterface {
13         /**The method which is called.
14          */
15         void call();
16 }
17
18 /**
19  * A callback which is called when a [`Future`] completes.
20  * 
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`]
23  * instead.
24  * 
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.
27  */
28 public class FutureCallback : CommonBase {
29         internal bindings.LDKFutureCallback bindings_instance;
30         internal long instance_idx;
31
32         internal FutureCallback(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
33         ~FutureCallback() {
34                 if (ptr != 0) { bindings.FutureCallback_free(ptr); }
35         }
36
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;
42                 public void call() {
43                         arg.call();
44                                 GC.KeepAlive(arg);
45                 }
46         }
47
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);
53
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;
58         }
59
60         /**
61          * The method which is called.
62          */
63         public void call() {
64                 bindings.FutureCallback_call(this.ptr);
65                 GC.KeepAlive(this);
66         }
67
68 }
69 } } }