[C#] Update auto-generated files
[ldk-java] / c_sharp / src / org / ldk / structs / APIError.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  * Indicates an error on the client's part (usually some variant of attempting to use too-low or
10  * too-high values)
11  */
12 public class APIError : CommonBase {
13         protected APIError(object _dummy, long ptr) : base(ptr) { }
14         ~APIError() {
15                 if (ptr != 0) { bindings.APIError_free(ptr); }
16         }
17
18         internal static APIError constr_from_ptr(long ptr) {
19                 long raw_ty = bindings.LDKAPIError_ty_from_ptr(ptr);
20                 switch (raw_ty) {
21                         case 0: return new APIError_APIMisuseError(ptr);
22                         case 1: return new APIError_FeeRateTooHigh(ptr);
23                         case 2: return new APIError_InvalidRoute(ptr);
24                         case 3: return new APIError_ChannelUnavailable(ptr);
25                         case 4: return new APIError_MonitorUpdateInProgress(ptr);
26                         case 5: return new APIError_IncompatibleShutdownScript(ptr);
27                         default:
28                                 throw new ArgumentException("Impossible enum variant");
29                 }
30         }
31
32         /** A APIError of type APIMisuseError */
33         public class APIError_APIMisuseError : APIError {
34                 /**
35                  * A human-readable error message
36                  */
37                 public string err;
38                 internal APIError_APIMisuseError(long ptr) : base(null, ptr) {
39                         this.err = bindings.LDKAPIError_APIMisuseError_get_err(ptr);
40                 }
41         }
42         /** A APIError of type FeeRateTooHigh */
43         public class APIError_FeeRateTooHigh : APIError {
44                 /**
45                  * A human-readable error message
46                  */
47                 public string err;
48                 /**
49                  * The feerate which was too high.
50                  */
51                 public int feerate;
52                 internal APIError_FeeRateTooHigh(long ptr) : base(null, ptr) {
53                         this.err = bindings.LDKAPIError_FeeRateTooHigh_get_err(ptr);
54                         this.feerate = bindings.LDKAPIError_FeeRateTooHigh_get_feerate(ptr);
55                 }
56         }
57         /** A APIError of type InvalidRoute */
58         public class APIError_InvalidRoute : APIError {
59                 /**
60                  * A human-readable error message
61                  */
62                 public string err;
63                 internal APIError_InvalidRoute(long ptr) : base(null, ptr) {
64                         this.err = bindings.LDKAPIError_InvalidRoute_get_err(ptr);
65                 }
66         }
67         /** A APIError of type ChannelUnavailable */
68         public class APIError_ChannelUnavailable : APIError {
69                 /**
70                  * A human-readable error message
71                  */
72                 public string err;
73                 internal APIError_ChannelUnavailable(long ptr) : base(null, ptr) {
74                         this.err = bindings.LDKAPIError_ChannelUnavailable_get_err(ptr);
75                 }
76         }
77         /** A APIError of type MonitorUpdateInProgress */
78         public class APIError_MonitorUpdateInProgress : APIError {
79                 internal APIError_MonitorUpdateInProgress(long ptr) : base(null, ptr) {
80                 }
81         }
82         /** A APIError of type IncompatibleShutdownScript */
83         public class APIError_IncompatibleShutdownScript : APIError {
84                 /**
85                  * The incompatible shutdown script.
86                  */
87                 public ShutdownScript script;
88                 internal APIError_IncompatibleShutdownScript(long ptr) : base(null, ptr) {
89                         long script = bindings.LDKAPIError_IncompatibleShutdownScript_get_script(ptr);
90                         org.ldk.structs.ShutdownScript script_hu_conv = null; if (script < 0 || script > 4096) { script_hu_conv = new org.ldk.structs.ShutdownScript(null, script); }
91                         if (script_hu_conv != null) { script_hu_conv.ptrs_to.AddLast(this); };
92                         this.script = script_hu_conv;
93                 }
94         }
95         internal long clone_ptr() {
96                 long ret = bindings.APIError_clone_ptr(this.ptr);
97                 GC.KeepAlive(this);
98                 return ret;
99         }
100
101         /**
102          * Creates a copy of the APIError
103          */
104         public APIError clone() {
105                 long ret = bindings.APIError_clone(this.ptr);
106                 GC.KeepAlive(this);
107                 if (ret >= 0 && ret <= 4096) { return null; }
108                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
109                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
110                 return ret_hu_conv;
111         }
112
113         /**
114          * Utility method to constructs a new APIMisuseError-variant APIError
115          */
116         public static APIError apimisuse_error(string err) {
117                 long ret = bindings.APIError_apimisuse_error(err);
118                 GC.KeepAlive(err);
119                 if (ret >= 0 && ret <= 4096) { return null; }
120                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
121                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
122                 return ret_hu_conv;
123         }
124
125         /**
126          * Utility method to constructs a new FeeRateTooHigh-variant APIError
127          */
128         public static APIError fee_rate_too_high(string err, int feerate) {
129                 long ret = bindings.APIError_fee_rate_too_high(err, feerate);
130                 GC.KeepAlive(err);
131                 GC.KeepAlive(feerate);
132                 if (ret >= 0 && ret <= 4096) { return null; }
133                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
134                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
135                 return ret_hu_conv;
136         }
137
138         /**
139          * Utility method to constructs a new InvalidRoute-variant APIError
140          */
141         public static APIError invalid_route(string err) {
142                 long ret = bindings.APIError_invalid_route(err);
143                 GC.KeepAlive(err);
144                 if (ret >= 0 && ret <= 4096) { return null; }
145                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
146                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
147                 return ret_hu_conv;
148         }
149
150         /**
151          * Utility method to constructs a new ChannelUnavailable-variant APIError
152          */
153         public static APIError channel_unavailable(string err) {
154                 long ret = bindings.APIError_channel_unavailable(err);
155                 GC.KeepAlive(err);
156                 if (ret >= 0 && ret <= 4096) { return null; }
157                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.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 MonitorUpdateInProgress-variant APIError
164          */
165         public static APIError monitor_update_in_progress() {
166                 long ret = bindings.APIError_monitor_update_in_progress();
167                 if (ret >= 0 && ret <= 4096) { return null; }
168                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.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 IncompatibleShutdownScript-variant APIError
175          */
176         public static APIError incompatible_shutdown_script(org.ldk.structs.ShutdownScript script) {
177                 long ret = bindings.APIError_incompatible_shutdown_script(script == null ? 0 : script.ptr);
178                 GC.KeepAlive(script);
179                 if (ret >= 0 && ret <= 4096) { return null; }
180                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
181                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
182                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(script); };
183                 return ret_hu_conv;
184         }
185
186         /**
187          * Checks if two APIErrors contain equal inner contents.
188          * This ignores pointers and is_owned flags and looks at the values in fields.
189          */
190         public bool eq(org.ldk.structs.APIError b) {
191                 bool ret = bindings.APIError_eq(this.ptr, b == null ? 0 : b.ptr);
192                 GC.KeepAlive(this);
193                 GC.KeepAlive(b);
194                 return ret;
195         }
196
197         public override bool Equals(object o) {
198                 if (!(o is APIError)) return false;
199                 return this.eq((APIError)o);
200         }
201         /**
202          * Serialize the APIError object into a byte array which can be read by APIError_read
203          */
204         public byte[] write() {
205                 byte[] ret = bindings.APIError_write(this.ptr);
206                 GC.KeepAlive(this);
207                 return ret;
208         }
209
210 }
211 } } }