[C#] Check in initial 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                 int ret_conv_14_len = ret.Length;
22                 RouteHintHop[] ret_conv_14_arr = new RouteHintHop[ret_conv_14_len];
23                 for (int o = 0; o < ret_conv_14_len; o++) {
24                         long ret_conv_14 = ret[o];
25                         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); }
26                         if (ret_conv_14_hu_conv != null) { ret_conv_14_hu_conv.ptrs_to.AddLast(this); };
27                         ret_conv_14_arr[o] = ret_conv_14_hu_conv;
28                 }
29                 return ret_conv_14_arr;
30         }
31
32         public void set_a(RouteHintHop[] val) {
33                 bindings.RouteHint_set_a(this.ptr, val != null ? InternalUtils.mapArray(val, val_conv_14 => val_conv_14 == null ? 0 : val_conv_14.ptr) : null);
34                 GC.KeepAlive(this);
35                 GC.KeepAlive(val);
36                 foreach (RouteHintHop val_conv_14 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_14); }; };
37         }
38
39         /**
40          * Constructs a new RouteHint given each field
41          */
42         public static RouteHint of(RouteHintHop[] a_arg) {
43                 long ret = bindings.RouteHint_new(a_arg != null ? InternalUtils.mapArray(a_arg, a_arg_conv_14 => a_arg_conv_14 == null ? 0 : a_arg_conv_14.ptr) : null);
44                 GC.KeepAlive(a_arg);
45                 if (ret >= 0 && ret <= 4096) { return null; }
46                 org.ldk.structs.RouteHint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHint(null, ret); }
47                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
48                 foreach (RouteHintHop a_arg_conv_14 in a_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a_arg_conv_14); }; };
49                 return ret_hu_conv;
50         }
51
52         internal long clone_ptr() {
53                 long ret = bindings.RouteHint_clone_ptr(this.ptr);
54                 GC.KeepAlive(this);
55                 return ret;
56         }
57
58         /**
59          * Creates a copy of the RouteHint
60          */
61         public RouteHint clone() {
62                 long ret = bindings.RouteHint_clone(this.ptr);
63                 GC.KeepAlive(this);
64                 if (ret >= 0 && ret <= 4096) { return null; }
65                 org.ldk.structs.RouteHint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHint(null, ret); }
66                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
67                 return ret_hu_conv;
68         }
69
70         /**
71          * Checks if two RouteHints contain equal inner contents.
72          */
73         public long hash() {
74                 long ret = bindings.RouteHint_hash(this.ptr);
75                 GC.KeepAlive(this);
76                 return ret;
77         }
78
79         public override int GetHashCode() {
80                 return (int)this.hash();
81         }
82         /**
83          * Checks if two RouteHints contain equal inner contents.
84          * This ignores pointers and is_owned flags and looks at the values in fields.
85          * Two objects with NULL inner values will be considered "equal" here.
86          */
87         public bool eq(org.ldk.structs.RouteHint b) {
88                 bool ret = bindings.RouteHint_eq(this.ptr, b == null ? 0 : b.ptr);
89                 GC.KeepAlive(this);
90                 GC.KeepAlive(b);
91                 if (this != null) { this.ptrs_to.AddLast(b); };
92                 return ret;
93         }
94
95         public override bool Equals(object o) {
96                 if (!(o is RouteHint)) return false;
97                 return this.eq((RouteHint)o);
98         }
99         /**
100          * Serialize the RouteHint object into a byte array which can be read by RouteHint_read
101          */
102         public byte[] write() {
103                 byte[] ret = bindings.RouteHint_write(this.ptr);
104                 GC.KeepAlive(this);
105                 return ret;
106         }
107
108         /**
109          * Read a RouteHint from a byte array, created by RouteHint_write
110          */
111         public static Result_RouteHintDecodeErrorZ read(byte[] ser) {
112                 long ret = bindings.RouteHint_read(ser);
113                 GC.KeepAlive(ser);
114                 if (ret >= 0 && ret <= 4096) { return null; }
115                 Result_RouteHintDecodeErrorZ ret_hu_conv = Result_RouteHintDecodeErrorZ.constr_from_ptr(ret);
116                 return ret_hu_conv;
117         }
118
119 }
120 } } }