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