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