[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / RouteHint.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * A list of hops along a payment path terminating with a channel to the recipient.
11  */
12 public class RouteHint : CommonBase {
13         internal RouteHint(object _dummy, long ptr) : base(ptr) { }
14         ~RouteHint() {
15                 if (ptr != 0) { bindings.RouteHint_free(ptr); }
16         }
17
18         public RouteHintHop[] get_a() {
19                 long ret = bindings.RouteHint_get_a(this.ptr);
20                 GC.KeepAlive(this);
21                 if (ret >= 0 && ret <= 4096) { return null; }
22                 int ret_conv_14_len = InternalUtils.getArrayLength(ret);
23                 RouteHintHop[] ret_conv_14_arr = new RouteHintHop[ret_conv_14_len];
24                 for (int o = 0; o < ret_conv_14_len; o++) {
25                         long ret_conv_14 = InternalUtils.getU64ArrayElem(ret, o);
26                         org.ldk.structs.RouteHintHop ret_conv_14_hu_conv = null; if (ret_conv_14 < 0 || ret_conv_14 > 4096) { ret_conv_14_hu_conv = new org.ldk.structs.RouteHintHop(null, ret_conv_14); }
27                         if (ret_conv_14_hu_conv != null) { ret_conv_14_hu_conv.ptrs_to.AddLast(this); };
28                         ret_conv_14_arr[o] = ret_conv_14_hu_conv;
29                 }
30                 bindings.free_buffer(ret);
31                 return ret_conv_14_arr;
32         }
33
34         public void set_a(RouteHintHop[] val) {
35                 bindings.RouteHint_set_a(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_14 => val_conv_14 == null ? 0 : val_conv_14.ptr)));
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38                 foreach (RouteHintHop val_conv_14 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_14); }; };
39         }
40
41         /**
42          * Constructs a new RouteHint given each field
43          */
44         public static RouteHint of(RouteHintHop[] a_arg) {
45                 long ret = bindings.RouteHint_new(InternalUtils.encodeUint64Array(InternalUtils.mapArray(a_arg, a_arg_conv_14 => a_arg_conv_14 == null ? 0 : a_arg_conv_14.ptr)));
46                 GC.KeepAlive(a_arg);
47                 if (ret >= 0 && ret <= 4096) { return null; }
48                 org.ldk.structs.RouteHint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHint(null, ret); }
49                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
50                 foreach (RouteHintHop a_arg_conv_14 in a_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a_arg_conv_14); }; };
51                 return ret_hu_conv;
52         }
53
54         internal long clone_ptr() {
55                 long ret = bindings.RouteHint_clone_ptr(this.ptr);
56                 GC.KeepAlive(this);
57                 return ret;
58         }
59
60         /**
61          * Creates a copy of the RouteHint
62          */
63         public RouteHint clone() {
64                 long ret = bindings.RouteHint_clone(this.ptr);
65                 GC.KeepAlive(this);
66                 if (ret >= 0 && ret <= 4096) { return null; }
67                 org.ldk.structs.RouteHint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHint(null, ret); }
68                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
69                 return ret_hu_conv;
70         }
71
72         /**
73          * Generates a non-cryptographic 64-bit hash of the RouteHint.
74          */
75         public long hash() {
76                 long ret = bindings.RouteHint_hash(this.ptr);
77                 GC.KeepAlive(this);
78                 return ret;
79         }
80
81         public override int GetHashCode() {
82                 return (int)this.hash();
83         }
84         /**
85          * Checks if two RouteHints contain equal inner contents.
86          * This ignores pointers and is_owned flags and looks at the values in fields.
87          * Two objects with NULL inner values will be considered "equal" here.
88          */
89         public bool eq(org.ldk.structs.RouteHint b) {
90                 bool ret = bindings.RouteHint_eq(this.ptr, b == null ? 0 : b.ptr);
91                 GC.KeepAlive(this);
92                 GC.KeepAlive(b);
93                 if (this != null) { this.ptrs_to.AddLast(b); };
94                 return ret;
95         }
96
97         public override bool Equals(object o) {
98                 if (!(o is RouteHint)) return false;
99                 return this.eq((RouteHint)o);
100         }
101         /**
102          * Serialize the RouteHint object into a byte array which can be read by RouteHint_read
103          */
104         public byte[] write() {
105                 long ret = bindings.RouteHint_write(this.ptr);
106                 GC.KeepAlive(this);
107                 if (ret >= 0 && ret <= 4096) { return null; }
108                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
109                 return ret_conv;
110         }
111
112         /**
113          * Read a RouteHint from a byte array, created by RouteHint_write
114          */
115         public static Result_RouteHintDecodeErrorZ read(byte[] ser) {
116                 long ret = bindings.RouteHint_read(InternalUtils.encodeUint8Array(ser));
117                 GC.KeepAlive(ser);
118                 if (ret >= 0 && ret <= 4096) { return null; }
119                 Result_RouteHintDecodeErrorZ ret_hu_conv = Result_RouteHintDecodeErrorZ.constr_from_ptr(ret);
120                 return ret_hu_conv;
121         }
122
123 }
124 } } }