[TS] Update tests for LDK 0.0.121 API
[ldk-java] / c_sharp / src / org / ldk / structs / ProbingError.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 that may occur when sending a payment probe.
10  */
11 public class ProbingError : CommonBase {
12         protected ProbingError(object _dummy, long ptr) : base(ptr) { }
13         ~ProbingError() {
14                 if (ptr != 0) { bindings.ProbingError_free(ptr); }
15         }
16
17         internal static ProbingError constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKProbingError_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new ProbingError_Invoice(ptr);
21                         case 1: return new ProbingError_Sending(ptr);
22                         default:
23                                 throw new ArgumentException("Impossible enum variant");
24                 }
25         }
26
27         /** A ProbingError of type Invoice */
28         public class ProbingError_Invoice : ProbingError {
29                 public string invoice;
30                 internal ProbingError_Invoice(long ptr) : base(null, ptr) {
31                         long invoice = bindings.LDKProbingError_Invoice_get_invoice(ptr);
32                         string invoice_conv = InternalUtils.decodeString(invoice);
33                         this.invoice = invoice_conv;
34                 }
35         }
36         /** A ProbingError of type Sending */
37         public class ProbingError_Sending : ProbingError {
38                 public ProbeSendFailure sending;
39                 internal ProbingError_Sending(long ptr) : base(null, ptr) {
40                         long sending = bindings.LDKProbingError_Sending_get_sending(ptr);
41                         org.ldk.structs.ProbeSendFailure sending_hu_conv = org.ldk.structs.ProbeSendFailure.constr_from_ptr(sending);
42                         if (sending_hu_conv != null) { sending_hu_conv.ptrs_to.AddLast(this); };
43                         this.sending = sending_hu_conv;
44                 }
45         }
46         internal long clone_ptr() {
47                 long ret = bindings.ProbingError_clone_ptr(this.ptr);
48                 GC.KeepAlive(this);
49                 return ret;
50         }
51
52         /**
53          * Creates a copy of the ProbingError
54          */
55         public ProbingError clone() {
56                 long ret = bindings.ProbingError_clone(this.ptr);
57                 GC.KeepAlive(this);
58                 if (ret >= 0 && ret <= 4096) { return null; }
59                 org.ldk.structs.ProbingError ret_hu_conv = org.ldk.structs.ProbingError.constr_from_ptr(ret);
60                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
61                 return ret_hu_conv;
62         }
63
64         /**
65          * Utility method to constructs a new Invoice-variant ProbingError
66          */
67         public static ProbingError invoice(string a) {
68                 long ret = bindings.ProbingError_invoice(InternalUtils.encodeString(a));
69                 GC.KeepAlive(a);
70                 if (ret >= 0 && ret <= 4096) { return null; }
71                 org.ldk.structs.ProbingError ret_hu_conv = org.ldk.structs.ProbingError.constr_from_ptr(ret);
72                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
73                 return ret_hu_conv;
74         }
75
76         /**
77          * Utility method to constructs a new Sending-variant ProbingError
78          */
79         public static ProbingError sending(org.ldk.structs.ProbeSendFailure a) {
80                 long ret = bindings.ProbingError_sending(a.ptr);
81                 GC.KeepAlive(a);
82                 if (ret >= 0 && ret <= 4096) { return null; }
83                 org.ldk.structs.ProbingError ret_hu_conv = org.ldk.structs.ProbingError.constr_from_ptr(ret);
84                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
85                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
86                 return ret_hu_conv;
87         }
88
89         /**
90          * Checks if two ProbingErrors contain equal inner contents.
91          * This ignores pointers and is_owned flags and looks at the values in fields.
92          */
93         public bool eq(org.ldk.structs.ProbingError b) {
94                 bool ret = bindings.ProbingError_eq(this.ptr, b == null ? 0 : b.ptr);
95                 GC.KeepAlive(this);
96                 GC.KeepAlive(b);
97                 return ret;
98         }
99
100         public override bool Equals(object o) {
101                 if (!(o is ProbingError)) return false;
102                 return this.eq((ProbingError)o);
103         }
104 }
105 } } }