6 namespace org { namespace ldk { namespace structs {
9 * An error in decoding a message or struct.
11 public class DecodeError : CommonBase {
12 protected DecodeError(object _dummy, long ptr) : base(ptr) { }
14 if (ptr != 0) { bindings.DecodeError_free(ptr); }
17 internal static DecodeError constr_from_ptr(long ptr) {
18 long raw_ty = bindings.LDKDecodeError_ty_from_ptr(ptr);
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);
29 throw new ArgumentException("Impossible enum variant");
33 /** A DecodeError of type UnknownVersion */
34 public class DecodeError_UnknownVersion : DecodeError {
35 internal DecodeError_UnknownVersion(long ptr) : base(null, ptr) {
38 /** A DecodeError of type UnknownRequiredFeature */
39 public class DecodeError_UnknownRequiredFeature : DecodeError {
40 internal DecodeError_UnknownRequiredFeature(long ptr) : base(null, ptr) {
43 /** A DecodeError of type InvalidValue */
44 public class DecodeError_InvalidValue : DecodeError {
45 internal DecodeError_InvalidValue(long ptr) : base(null, ptr) {
48 /** A DecodeError of type ShortRead */
49 public class DecodeError_ShortRead : DecodeError {
50 internal DecodeError_ShortRead(long ptr) : base(null, ptr) {
53 /** A DecodeError of type BadLengthDescriptor */
54 public class DecodeError_BadLengthDescriptor : DecodeError {
55 internal DecodeError_BadLengthDescriptor(long ptr) : base(null, ptr) {
58 /** A DecodeError of type Io */
59 public class DecodeError_Io : DecodeError {
61 internal DecodeError_Io(long ptr) : base(null, ptr) {
62 this.io = bindings.LDKDecodeError_Io_get_io(ptr);
65 /** A DecodeError of type UnsupportedCompression */
66 public class DecodeError_UnsupportedCompression : DecodeError {
67 internal DecodeError_UnsupportedCompression(long ptr) : base(null, ptr) {
70 /** A DecodeError of type DangerousValue */
71 public class DecodeError_DangerousValue : DecodeError {
72 internal DecodeError_DangerousValue(long ptr) : base(null, ptr) {
75 internal long clone_ptr() {
76 long ret = bindings.DecodeError_clone_ptr(this.ptr);
82 * Creates a copy of the DecodeError
84 public DecodeError clone() {
85 long ret = bindings.DecodeError_clone(this.ptr);
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); };
94 * Utility method to constructs a new UnknownVersion-variant DecodeError
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); };
105 * Utility method to constructs a new UnknownRequiredFeature-variant DecodeError
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); };
116 * Utility method to constructs a new InvalidValue-variant DecodeError
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); };
127 * Utility method to constructs a new ShortRead-variant DecodeError
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); };
138 * Utility method to constructs a new BadLengthDescriptor-variant DecodeError
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); };
149 * Utility method to constructs a new Io-variant DecodeError
151 public static DecodeError io(IOError a) {
152 long ret = bindings.DecodeError_io(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); };
161 * Utility method to constructs a new UnsupportedCompression-variant DecodeError
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); };
172 * Utility method to constructs a new DangerousValue-variant DecodeError
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); };
183 * Generates a non-cryptographic 64-bit hash of the DecodeError.
186 long ret = bindings.DecodeError_hash(this.ptr);
191 public override int GetHashCode() {
192 return (int)this.hash();
195 * Checks if two DecodeErrors contain equal inner contents.
196 * This ignores pointers and is_owned flags and looks at the values in fields.
198 public bool eq(org.ldk.structs.DecodeError b) {
199 bool ret = bindings.DecodeError_eq(this.ptr, b.ptr);
205 public override bool Equals(object o) {
206 if (!(o is DecodeError)) return false;
207 return this.eq((DecodeError)o);