[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Score.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 Score */
12 public interface ScoreInterface {
13         /**Serialize the object into a byte array
14          */
15         byte[] write();
16 }
17
18 /**
19  * A trait which can both lookup and update routing channel penalty scores.
20  * 
21  * This is used in places where both bounds are required and implemented for all types which
22  * implement [`ScoreLookUp`] and [`ScoreUpdate`].
23  * 
24  * Bindings users may need to manually implement this for their custom scoring implementations.
25  */
26 public class Score : CommonBase {
27         internal bindings.LDKScore bindings_instance;
28         internal long instance_idx;
29
30         internal Score(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
31         ~Score() {
32                 if (ptr != 0) { bindings.Score_free(ptr); }
33         }
34
35         private class LDKScoreHolder { internal Score held; }
36         private class LDKScoreImpl : bindings.LDKScore {
37                 internal LDKScoreImpl(ScoreInterface arg, LDKScoreHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
38                 private ScoreInterface arg;
39                 private LDKScoreHolder impl_holder;
40                 public long write() {
41                         byte[] ret = arg.write();
42                                 GC.KeepAlive(arg);
43                         long result = InternalUtils.encodeUint8Array(ret);
44                         return result;
45                 }
46         }
47
48         /** Creates a new instance of Score from a given implementation */
49         public static Score new_impl(ScoreInterface arg, ScoreLookUpInterface scoreLookUp_impl, ScoreUpdateInterface scoreUpdate_impl) {
50                 LDKScoreHolder impl_holder = new LDKScoreHolder();
51                 LDKScoreImpl impl = new LDKScoreImpl(arg, impl_holder);
52                 ScoreLookUp scoreLookUp = ScoreLookUp.new_impl(scoreLookUp_impl);
53                 ScoreUpdate scoreUpdate = ScoreUpdate.new_impl(scoreUpdate_impl);
54                 long[] ptr_idx = bindings.LDKScore_new(impl, scoreLookUp.instance_idx, scoreUpdate.instance_idx);
55
56                 impl_holder.held = new Score(null, ptr_idx[0]);
57                 impl_holder.held.instance_idx = ptr_idx[1];
58                 impl_holder.held.bindings_instance = impl;
59                 impl_holder.held.ptrs_to.AddLast(scoreLookUp);
60                 impl_holder.held.ptrs_to.AddLast(scoreUpdate);
61                 return impl_holder.held;
62         }
63
64         /**
65          * Serialize the object into a byte array
66          */
67         public byte[] write() {
68                 long ret = bindings.Score_write(this.ptr);
69                 GC.KeepAlive(this);
70                 if (ret >= 0 && ret <= 4096) { return null; }
71                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
72                 return ret_conv;
73         }
74
75 }
76 } } }