[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / WriteableScore.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 WriteableScore */
12 public interface WriteableScoreInterface {
13         /**Serialize the object into a byte array
14          */
15         byte[] write();
16 }
17
18 /**
19  * Refers to a scorer that is accessible under lock and also writeable to disk
20  * 
21  * We need this trait to be able to pass in a scorer to `lightning-background-processor` that will enable us to
22  * use the Persister to persist it.
23  */
24 public class WriteableScore : CommonBase {
25         internal bindings.LDKWriteableScore bindings_instance;
26         internal long instance_idx;
27
28         internal WriteableScore(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
29         ~WriteableScore() {
30                 if (ptr != 0) { bindings.WriteableScore_free(ptr); }
31         }
32
33         private class LDKWriteableScoreHolder { internal WriteableScore held; }
34         private class LDKWriteableScoreImpl : bindings.LDKWriteableScore {
35                 internal LDKWriteableScoreImpl(WriteableScoreInterface arg, LDKWriteableScoreHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
36                 private WriteableScoreInterface arg;
37                 private LDKWriteableScoreHolder impl_holder;
38                 public long write() {
39                         byte[] ret = arg.write();
40                                 GC.KeepAlive(arg);
41                         long result = InternalUtils.encodeUint8Array(ret);
42                         return result;
43                 }
44         }
45
46         /** Creates a new instance of WriteableScore from a given implementation */
47         public static WriteableScore new_impl(WriteableScoreInterface arg, LockableScoreInterface lockableScore_impl) {
48                 LDKWriteableScoreHolder impl_holder = new LDKWriteableScoreHolder();
49                 LDKWriteableScoreImpl impl = new LDKWriteableScoreImpl(arg, impl_holder);
50                 LockableScore lockableScore = LockableScore.new_impl(lockableScore_impl);
51                 long[] ptr_idx = bindings.LDKWriteableScore_new(impl, lockableScore.instance_idx);
52
53                 impl_holder.held = new WriteableScore(null, ptr_idx[0]);
54                 impl_holder.held.instance_idx = ptr_idx[1];
55                 impl_holder.held.bindings_instance = impl;
56                 impl_holder.held.ptrs_to.AddLast(lockableScore);
57                 return impl_holder.held;
58         }
59
60         /**
61          * Serialize the object into a byte array
62          */
63         public byte[] write() {
64                 long ret = bindings.WriteableScore_write(this.ptr);
65                 GC.KeepAlive(this);
66                 if (ret >= 0 && ret <= 4096) { return null; }
67                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
68                 return ret_conv;
69         }
70
71 }
72 } } }