5e557bd1965ca060177803e0a30fb1607d658402
[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_InvalidMessage(ptr);
27                         case 5: return new SendError_BufferFull(ptr);
28                         case 6: return new SendError_GetNodeIdFailed(ptr);
29                         case 7: return new SendError_BlindedPathAdvanceFailed(ptr);
30                         default:
31                                 throw new ArgumentException("Impossible enum variant");
32                 }
33         }
34
35         /** A SendError of type Secp256k1 */
36         public class SendError_Secp256k1 : SendError {
37                 public Secp256k1Error secp256k1;
38                 internal SendError_Secp256k1(long ptr) : base(null, ptr) {
39                         this.secp256k1 = bindings.LDKSendError_Secp256k1_get_secp256k1(ptr);
40                 }
41         }
42         /** A SendError of type TooBigPacket */
43         public class SendError_TooBigPacket : SendError {
44                 internal SendError_TooBigPacket(long ptr) : base(null, ptr) {
45                 }
46         }
47         /** A SendError of type TooFewBlindedHops */
48         public class SendError_TooFewBlindedHops : SendError {
49                 internal SendError_TooFewBlindedHops(long ptr) : base(null, ptr) {
50                 }
51         }
52         /** A SendError of type InvalidFirstHop */
53         public class SendError_InvalidFirstHop : SendError {
54                 internal SendError_InvalidFirstHop(long ptr) : base(null, ptr) {
55                 }
56         }
57         /** A SendError of type InvalidMessage */
58         public class SendError_InvalidMessage : SendError {
59                 internal SendError_InvalidMessage(long ptr) : base(null, ptr) {
60                 }
61         }
62         /** A SendError of type BufferFull */
63         public class SendError_BufferFull : SendError {
64                 internal SendError_BufferFull(long ptr) : base(null, ptr) {
65                 }
66         }
67         /** A SendError of type GetNodeIdFailed */
68         public class SendError_GetNodeIdFailed : SendError {
69                 internal SendError_GetNodeIdFailed(long ptr) : base(null, ptr) {
70                 }
71         }
72         /** A SendError of type BlindedPathAdvanceFailed */
73         public class SendError_BlindedPathAdvanceFailed : SendError {
74                 internal SendError_BlindedPathAdvanceFailed(long ptr) : base(null, ptr) {
75                 }
76         }
77         internal long clone_ptr() {
78                 long ret = bindings.SendError_clone_ptr(this.ptr);
79                 GC.KeepAlive(this);
80                 return ret;
81         }
82
83         /**
84          * Creates a copy of the SendError
85          */
86         public SendError clone() {
87                 long ret = bindings.SendError_clone(this.ptr);
88                 GC.KeepAlive(this);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
91                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
92                 return ret_hu_conv;
93         }
94
95         /**
96          * Utility method to constructs a new Secp256k1-variant SendError
97          */
98         public static SendError secp256k1(Secp256k1Error a) {
99                 long ret = bindings.SendError_secp256k1(a);
100                 GC.KeepAlive(a);
101                 if (ret >= 0 && ret <= 4096) { return null; }
102                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
103                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
104                 return ret_hu_conv;
105         }
106
107         /**
108          * Utility method to constructs a new TooBigPacket-variant SendError
109          */
110         public static SendError too_big_packet() {
111                 long ret = bindings.SendError_too_big_packet();
112                 if (ret >= 0 && ret <= 4096) { return null; }
113                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
114                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
115                 return ret_hu_conv;
116         }
117
118         /**
119          * Utility method to constructs a new TooFewBlindedHops-variant SendError
120          */
121         public static SendError too_few_blinded_hops() {
122                 long ret = bindings.SendError_too_few_blinded_hops();
123                 if (ret >= 0 && ret <= 4096) { return null; }
124                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
125                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
126                 return ret_hu_conv;
127         }
128
129         /**
130          * Utility method to constructs a new InvalidFirstHop-variant SendError
131          */
132         public static SendError invalid_first_hop() {
133                 long ret = bindings.SendError_invalid_first_hop();
134                 if (ret >= 0 && ret <= 4096) { return null; }
135                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
136                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
137                 return ret_hu_conv;
138         }
139
140         /**
141          * Utility method to constructs a new InvalidMessage-variant SendError
142          */
143         public static SendError invalid_message() {
144                 long ret = bindings.SendError_invalid_message();
145                 if (ret >= 0 && ret <= 4096) { return null; }
146                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
147                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
148                 return ret_hu_conv;
149         }
150
151         /**
152          * Utility method to constructs a new BufferFull-variant SendError
153          */
154         public static SendError buffer_full() {
155                 long ret = bindings.SendError_buffer_full();
156                 if (ret >= 0 && ret <= 4096) { return null; }
157                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
158                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
159                 return ret_hu_conv;
160         }
161
162         /**
163          * Utility method to constructs a new GetNodeIdFailed-variant SendError
164          */
165         public static SendError get_node_id_failed() {
166                 long ret = bindings.SendError_get_node_id_failed();
167                 if (ret >= 0 && ret <= 4096) { return null; }
168                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
169                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
170                 return ret_hu_conv;
171         }
172
173         /**
174          * Utility method to constructs a new BlindedPathAdvanceFailed-variant SendError
175          */
176         public static SendError blinded_path_advance_failed() {
177                 long ret = bindings.SendError_blinded_path_advance_failed();
178                 if (ret >= 0 && ret <= 4096) { return null; }
179                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
180                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
181                 return ret_hu_conv;
182         }
183
184         /**
185          * Checks if two SendErrors contain equal inner contents.
186          * This ignores pointers and is_owned flags and looks at the values in fields.
187          */
188         public bool eq(org.ldk.structs.SendError b) {
189                 bool ret = bindings.SendError_eq(this.ptr, b == null ? 0 : b.ptr);
190                 GC.KeepAlive(this);
191                 GC.KeepAlive(b);
192                 return ret;
193         }
194
195         public override bool Equals(object o) {
196                 if (!(o is SendError)) return false;
197                 return this.eq((SendError)o);
198         }
199 }
200 } } }