[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / DecodeError.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  * An error in decoding a message or struct.
10  */
11 public class DecodeError : CommonBase {
12         protected DecodeError(object _dummy, long ptr) : base(ptr) { }
13         ~DecodeError() {
14                 if (ptr != 0) { bindings.DecodeError_free(ptr); }
15         }
16
17         internal static DecodeError constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKDecodeError_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new DecodeError_UnknownVersion(ptr);
21                         case 1: return new DecodeError_UnknownRequiredFeature(ptr);
22                         case 2: return new DecodeError_InvalidValue(ptr);
23                         case 3: return new DecodeError_ShortRead(ptr);
24                         case 4: return new DecodeError_BadLengthDescriptor(ptr);
25                         case 5: return new DecodeError_Io(ptr);
26                         case 6: return new DecodeError_UnsupportedCompression(ptr);
27                         case 7: return new DecodeError_DangerousValue(ptr);
28                         default:
29                                 throw new ArgumentException("Impossible enum variant");
30                 }
31         }
32
33         /** A DecodeError of type UnknownVersion */
34         public class DecodeError_UnknownVersion : DecodeError {
35                 internal DecodeError_UnknownVersion(long ptr) : base(null, ptr) {
36                 }
37         }
38         /** A DecodeError of type UnknownRequiredFeature */
39         public class DecodeError_UnknownRequiredFeature : DecodeError {
40                 internal DecodeError_UnknownRequiredFeature(long ptr) : base(null, ptr) {
41                 }
42         }
43         /** A DecodeError of type InvalidValue */
44         public class DecodeError_InvalidValue : DecodeError {
45                 internal DecodeError_InvalidValue(long ptr) : base(null, ptr) {
46                 }
47         }
48         /** A DecodeError of type ShortRead */
49         public class DecodeError_ShortRead : DecodeError {
50                 internal DecodeError_ShortRead(long ptr) : base(null, ptr) {
51                 }
52         }
53         /** A DecodeError of type BadLengthDescriptor */
54         public class DecodeError_BadLengthDescriptor : DecodeError {
55                 internal DecodeError_BadLengthDescriptor(long ptr) : base(null, ptr) {
56                 }
57         }
58         /** A DecodeError of type Io */
59         public class DecodeError_Io : DecodeError {
60                 public IOError io;
61                 internal DecodeError_Io(long ptr) : base(null, ptr) {
62                         this.io = bindings.LDKDecodeError_Io_get_io(ptr);
63                 }
64         }
65         /** A DecodeError of type UnsupportedCompression */
66         public class DecodeError_UnsupportedCompression : DecodeError {
67                 internal DecodeError_UnsupportedCompression(long ptr) : base(null, ptr) {
68                 }
69         }
70         /** A DecodeError of type DangerousValue */
71         public class DecodeError_DangerousValue : DecodeError {
72                 internal DecodeError_DangerousValue(long ptr) : base(null, ptr) {
73                 }
74         }
75         internal long clone_ptr() {
76                 long ret = bindings.DecodeError_clone_ptr(this.ptr);
77                 GC.KeepAlive(this);
78                 return ret;
79         }
80
81         /**
82          * Creates a copy of the DecodeError
83          */
84         public DecodeError clone() {
85                 long ret = bindings.DecodeError_clone(this.ptr);
86                 GC.KeepAlive(this);
87                 if (ret >= 0 && ret <= 4096) { return null; }
88                 org.ldk.structs.DecodeError ret_hu_conv = org.ldk.structs.DecodeError.constr_from_ptr(ret);
89                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
90                 return ret_hu_conv;
91         }
92
93         /**
94          * Utility method to constructs a new UnknownVersion-variant DecodeError
95          */
96         public static DecodeError unknown_version() {
97                 long ret = bindings.DecodeError_unknown_version();
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 org.ldk.structs.DecodeError ret_hu_conv = org.ldk.structs.DecodeError.constr_from_ptr(ret);
100                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
101                 return ret_hu_conv;
102         }
103
104         /**
105          * Utility method to constructs a new UnknownRequiredFeature-variant DecodeError
106          */
107         public static DecodeError unknown_required_feature() {
108                 long ret = bindings.DecodeError_unknown_required_feature();
109                 if (ret >= 0 && ret <= 4096) { return null; }
110                 org.ldk.structs.DecodeError ret_hu_conv = org.ldk.structs.DecodeError.constr_from_ptr(ret);
111                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
112                 return ret_hu_conv;
113         }
114
115         /**
116          * Utility method to constructs a new InvalidValue-variant DecodeError
117          */
118         public static DecodeError invalid_value() {
119                 long ret = bindings.DecodeError_invalid_value();
120                 if (ret >= 0 && ret <= 4096) { return null; }
121                 org.ldk.structs.DecodeError ret_hu_conv = org.ldk.structs.DecodeError.constr_from_ptr(ret);
122                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
123                 return ret_hu_conv;
124         }
125
126         /**
127          * Utility method to constructs a new ShortRead-variant DecodeError
128          */
129         public static DecodeError short_read() {
130                 long ret = bindings.DecodeError_short_read();
131                 if (ret >= 0 && ret <= 4096) { return null; }
132                 org.ldk.structs.DecodeError ret_hu_conv = org.ldk.structs.DecodeError.constr_from_ptr(ret);
133                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
134                 return ret_hu_conv;
135         }
136
137         /**
138          * Utility method to constructs a new BadLengthDescriptor-variant DecodeError
139          */
140         public static DecodeError bad_length_descriptor() {
141                 long ret = bindings.DecodeError_bad_length_descriptor();
142                 if (ret >= 0 && ret <= 4096) { return null; }
143                 org.ldk.structs.DecodeError ret_hu_conv = org.ldk.structs.DecodeError.constr_from_ptr(ret);
144                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
145                 return ret_hu_conv;
146         }
147
148         /**
149          * Utility method to constructs a new Io-variant DecodeError
150          */
151         public static DecodeError io(IOError a) {
152                 long ret = bindings.DecodeError_io(a);
153                 GC.KeepAlive(a);
154                 if (ret >= 0 && ret <= 4096) { return null; }
155                 org.ldk.structs.DecodeError ret_hu_conv = org.ldk.structs.DecodeError.constr_from_ptr(ret);
156                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
157                 return ret_hu_conv;
158         }
159
160         /**
161          * Utility method to constructs a new UnsupportedCompression-variant DecodeError
162          */
163         public static DecodeError unsupported_compression() {
164                 long ret = bindings.DecodeError_unsupported_compression();
165                 if (ret >= 0 && ret <= 4096) { return null; }
166                 org.ldk.structs.DecodeError ret_hu_conv = org.ldk.structs.DecodeError.constr_from_ptr(ret);
167                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
168                 return ret_hu_conv;
169         }
170
171         /**
172          * Utility method to constructs a new DangerousValue-variant DecodeError
173          */
174         public static DecodeError dangerous_value() {
175                 long ret = bindings.DecodeError_dangerous_value();
176                 if (ret >= 0 && ret <= 4096) { return null; }
177                 org.ldk.structs.DecodeError ret_hu_conv = org.ldk.structs.DecodeError.constr_from_ptr(ret);
178                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
179                 return ret_hu_conv;
180         }
181
182         /**
183          * Generates a non-cryptographic 64-bit hash of the DecodeError.
184          */
185         public long hash() {
186                 long ret = bindings.DecodeError_hash(this.ptr);
187                 GC.KeepAlive(this);
188                 return ret;
189         }
190
191         public override int GetHashCode() {
192                 return (int)this.hash();
193         }
194         /**
195          * Checks if two DecodeErrors contain equal inner contents.
196          * This ignores pointers and is_owned flags and looks at the values in fields.
197          */
198         public bool eq(org.ldk.structs.DecodeError b) {
199                 bool ret = bindings.DecodeError_eq(this.ptr, b.ptr);
200                 GC.KeepAlive(this);
201                 GC.KeepAlive(b);
202                 return ret;
203         }
204
205         public override bool Equals(object o) {
206                 if (!(o is DecodeError)) return false;
207                 return this.eq((DecodeError)o);
208         }
209 }
210 } } }