[C#] Run tests against release library in determinism CI run
[ldk-java] / c_sharp / src / org / ldk / structs / SendError.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  * Errors that may occur when [sending an onion message].
10  * 
11  * [sending an onion message]: OnionMessenger::send_onion_message
12  */
13 public class SendError : CommonBase {
14         protected SendError(object _dummy, long ptr) : base(ptr) { }
15         ~SendError() {
16                 if (ptr != 0) { bindings.SendError_free(ptr); }
17         }
18
19         internal static SendError constr_from_ptr(long ptr) {
20                 long raw_ty = bindings.LDKSendError_ty_from_ptr(ptr);
21                 switch (raw_ty) {
22                         case 0: return new SendError_Secp256k1(ptr);
23                         case 1: return new SendError_TooBigPacket(ptr);
24                         case 2: return new SendError_TooFewBlindedHops(ptr);
25                         case 3: return new SendError_InvalidFirstHop(ptr);
26                         case 4: return new SendError_PathNotFound(ptr);
27                         case 5: return new SendError_InvalidMessage(ptr);
28                         case 6: return new SendError_BufferFull(ptr);
29                         case 7: return new SendError_GetNodeIdFailed(ptr);
30                         case 8: return new SendError_UnresolvedIntroductionNode(ptr);
31                         case 9: return new SendError_BlindedPathAdvanceFailed(ptr);
32                         default:
33                                 throw new ArgumentException("Impossible enum variant");
34                 }
35         }
36
37         /** A SendError of type Secp256k1 */
38         public class SendError_Secp256k1 : SendError {
39                 public Secp256k1Error secp256k1;
40                 internal SendError_Secp256k1(long ptr) : base(null, ptr) {
41                         this.secp256k1 = bindings.LDKSendError_Secp256k1_get_secp256k1(ptr);
42                 }
43         }
44         /** A SendError of type TooBigPacket */
45         public class SendError_TooBigPacket : SendError {
46                 internal SendError_TooBigPacket(long ptr) : base(null, ptr) {
47                 }
48         }
49         /** A SendError of type TooFewBlindedHops */
50         public class SendError_TooFewBlindedHops : SendError {
51                 internal SendError_TooFewBlindedHops(long ptr) : base(null, ptr) {
52                 }
53         }
54         /** A SendError of type InvalidFirstHop */
55         public class SendError_InvalidFirstHop : SendError {
56                 public byte[] invalid_first_hop;
57                 internal SendError_InvalidFirstHop(long ptr) : base(null, ptr) {
58                         long invalid_first_hop = bindings.LDKSendError_InvalidFirstHop_get_invalid_first_hop(ptr);
59                         byte[] invalid_first_hop_conv = InternalUtils.decodeUint8Array(invalid_first_hop);
60                         this.invalid_first_hop = invalid_first_hop_conv;
61                 }
62         }
63         /** A SendError of type PathNotFound */
64         public class SendError_PathNotFound : SendError {
65                 internal SendError_PathNotFound(long ptr) : base(null, ptr) {
66                 }
67         }
68         /** A SendError of type InvalidMessage */
69         public class SendError_InvalidMessage : SendError {
70                 internal SendError_InvalidMessage(long ptr) : base(null, ptr) {
71                 }
72         }
73         /** A SendError of type BufferFull */
74         public class SendError_BufferFull : SendError {
75                 internal SendError_BufferFull(long ptr) : base(null, ptr) {
76                 }
77         }
78         /** A SendError of type GetNodeIdFailed */
79         public class SendError_GetNodeIdFailed : SendError {
80                 internal SendError_GetNodeIdFailed(long ptr) : base(null, ptr) {
81                 }
82         }
83         /** A SendError of type UnresolvedIntroductionNode */
84         public class SendError_UnresolvedIntroductionNode : SendError {
85                 internal SendError_UnresolvedIntroductionNode(long ptr) : base(null, ptr) {
86                 }
87         }
88         /** A SendError of type BlindedPathAdvanceFailed */
89         public class SendError_BlindedPathAdvanceFailed : SendError {
90                 internal SendError_BlindedPathAdvanceFailed(long ptr) : base(null, ptr) {
91                 }
92         }
93         internal long clone_ptr() {
94                 long ret = bindings.SendError_clone_ptr(this.ptr);
95                 GC.KeepAlive(this);
96                 return ret;
97         }
98
99         /**
100          * Creates a copy of the SendError
101          */
102         public SendError clone() {
103                 long ret = bindings.SendError_clone(this.ptr);
104                 GC.KeepAlive(this);
105                 if (ret >= 0 && ret <= 4096) { return null; }
106                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
108                 return ret_hu_conv;
109         }
110
111         /**
112          * Utility method to constructs a new Secp256k1-variant SendError
113          */
114         public static SendError secp256k1(Secp256k1Error a) {
115                 long ret = bindings.SendError_secp256k1(a);
116                 GC.KeepAlive(a);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
119                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
120                 return ret_hu_conv;
121         }
122
123         /**
124          * Utility method to constructs a new TooBigPacket-variant SendError
125          */
126         public static SendError too_big_packet() {
127                 long ret = bindings.SendError_too_big_packet();
128                 if (ret >= 0 && ret <= 4096) { return null; }
129                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
130                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
131                 return ret_hu_conv;
132         }
133
134         /**
135          * Utility method to constructs a new TooFewBlindedHops-variant SendError
136          */
137         public static SendError too_few_blinded_hops() {
138                 long ret = bindings.SendError_too_few_blinded_hops();
139                 if (ret >= 0 && ret <= 4096) { return null; }
140                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
141                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
142                 return ret_hu_conv;
143         }
144
145         /**
146          * Utility method to constructs a new InvalidFirstHop-variant SendError
147          */
148         public static SendError invalid_first_hop(byte[] a) {
149                 long ret = bindings.SendError_invalid_first_hop(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(a, 33)));
150                 GC.KeepAlive(a);
151                 if (ret >= 0 && ret <= 4096) { return null; }
152                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
153                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
154                 return ret_hu_conv;
155         }
156
157         /**
158          * Utility method to constructs a new PathNotFound-variant SendError
159          */
160         public static SendError path_not_found() {
161                 long ret = bindings.SendError_path_not_found();
162                 if (ret >= 0 && ret <= 4096) { return null; }
163                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
164                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
165                 return ret_hu_conv;
166         }
167
168         /**
169          * Utility method to constructs a new InvalidMessage-variant SendError
170          */
171         public static SendError invalid_message() {
172                 long ret = bindings.SendError_invalid_message();
173                 if (ret >= 0 && ret <= 4096) { return null; }
174                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
175                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
176                 return ret_hu_conv;
177         }
178
179         /**
180          * Utility method to constructs a new BufferFull-variant SendError
181          */
182         public static SendError buffer_full() {
183                 long ret = bindings.SendError_buffer_full();
184                 if (ret >= 0 && ret <= 4096) { return null; }
185                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
186                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
187                 return ret_hu_conv;
188         }
189
190         /**
191          * Utility method to constructs a new GetNodeIdFailed-variant SendError
192          */
193         public static SendError get_node_id_failed() {
194                 long ret = bindings.SendError_get_node_id_failed();
195                 if (ret >= 0 && ret <= 4096) { return null; }
196                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
197                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
198                 return ret_hu_conv;
199         }
200
201         /**
202          * Utility method to constructs a new UnresolvedIntroductionNode-variant SendError
203          */
204         public static SendError unresolved_introduction_node() {
205                 long ret = bindings.SendError_unresolved_introduction_node();
206                 if (ret >= 0 && ret <= 4096) { return null; }
207                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
208                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
209                 return ret_hu_conv;
210         }
211
212         /**
213          * Utility method to constructs a new BlindedPathAdvanceFailed-variant SendError
214          */
215         public static SendError blinded_path_advance_failed() {
216                 long ret = bindings.SendError_blinded_path_advance_failed();
217                 if (ret >= 0 && ret <= 4096) { return null; }
218                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
219                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
220                 return ret_hu_conv;
221         }
222
223         /**
224          * Generates a non-cryptographic 64-bit hash of the SendError.
225          */
226         public long hash() {
227                 long ret = bindings.SendError_hash(this.ptr);
228                 GC.KeepAlive(this);
229                 return ret;
230         }
231
232         public override int GetHashCode() {
233                 return (int)this.hash();
234         }
235         /**
236          * Checks if two SendErrors contain equal inner contents.
237          * This ignores pointers and is_owned flags and looks at the values in fields.
238          */
239         public bool eq(org.ldk.structs.SendError b) {
240                 bool ret = bindings.SendError_eq(this.ptr, b.ptr);
241                 GC.KeepAlive(this);
242                 GC.KeepAlive(b);
243                 return ret;
244         }
245
246         public override bool Equals(object o) {
247                 if (!(o is SendError)) return false;
248                 return this.eq((SendError)o);
249         }
250 }
251 } } }