[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Retry.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  * Strategies available to retry payment path failures.
10  */
11 public class Retry : CommonBase {
12         protected Retry(object _dummy, long ptr) : base(ptr) { }
13         ~Retry() {
14                 if (ptr != 0) { bindings.Retry_free(ptr); }
15         }
16
17         internal static Retry constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKRetry_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new Retry_Attempts(ptr);
21                         case 1: return new Retry_Timeout(ptr);
22                         default:
23                                 throw new ArgumentException("Impossible enum variant");
24                 }
25         }
26
27         /** A Retry of type Attempts */
28         public class Retry_Attempts : Retry {
29                 public int attempts;
30                 internal Retry_Attempts(long ptr) : base(null, ptr) {
31                         this.attempts = bindings.LDKRetry_Attempts_get_attempts(ptr);
32                 }
33         }
34         /** A Retry of type Timeout */
35         public class Retry_Timeout : Retry {
36                 public long timeout;
37                 internal Retry_Timeout(long ptr) : base(null, ptr) {
38                         this.timeout = bindings.LDKRetry_Timeout_get_timeout(ptr);
39                 }
40         }
41         internal long clone_ptr() {
42                 long ret = bindings.Retry_clone_ptr(this.ptr);
43                 GC.KeepAlive(this);
44                 return ret;
45         }
46
47         /**
48          * Creates a copy of the Retry
49          */
50         public Retry clone() {
51                 long ret = bindings.Retry_clone(this.ptr);
52                 GC.KeepAlive(this);
53                 if (ret >= 0 && ret <= 4096) { return null; }
54                 org.ldk.structs.Retry ret_hu_conv = org.ldk.structs.Retry.constr_from_ptr(ret);
55                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
56                 return ret_hu_conv;
57         }
58
59         /**
60          * Utility method to constructs a new Attempts-variant Retry
61          */
62         public static Retry attempts(int a) {
63                 long ret = bindings.Retry_attempts(a);
64                 GC.KeepAlive(a);
65                 if (ret >= 0 && ret <= 4096) { return null; }
66                 org.ldk.structs.Retry ret_hu_conv = org.ldk.structs.Retry.constr_from_ptr(ret);
67                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
68                 return ret_hu_conv;
69         }
70
71         /**
72          * Utility method to constructs a new Timeout-variant Retry
73          */
74         public static Retry timeout(long a) {
75                 long ret = bindings.Retry_timeout(a);
76                 GC.KeepAlive(a);
77                 if (ret >= 0 && ret <= 4096) { return null; }
78                 org.ldk.structs.Retry ret_hu_conv = org.ldk.structs.Retry.constr_from_ptr(ret);
79                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
80                 return ret_hu_conv;
81         }
82
83         /**
84          * Checks if two Retrys contain equal inner contents.
85          * This ignores pointers and is_owned flags and looks at the values in fields.
86          */
87         public bool eq(org.ldk.structs.Retry b) {
88                 bool ret = bindings.Retry_eq(this.ptr, b == null ? 0 : b.ptr);
89                 GC.KeepAlive(this);
90                 GC.KeepAlive(b);
91                 return ret;
92         }
93
94         public override bool Equals(object o) {
95                 if (!(o is Retry)) return false;
96                 return this.eq((Retry)o);
97         }
98         /**
99          * Generates a non-cryptographic 64-bit hash of the Retry.
100          */
101         public long hash() {
102                 long ret = bindings.Retry_hash(this.ptr);
103                 GC.KeepAlive(this);
104                 return ret;
105         }
106
107         public override int GetHashCode() {
108                 return (int)this.hash();
109         }
110         /**
111          * Serialize the Retry object into a byte array which can be read by Retry_read
112          */
113         public byte[] write() {
114                 long ret = bindings.Retry_write(this.ptr);
115                 GC.KeepAlive(this);
116                 if (ret >= 0 && ret <= 4096) { return null; }
117                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
118                 return ret_conv;
119         }
120
121         /**
122          * Read a Retry from a byte array, created by Retry_write
123          */
124         public static Result_RetryDecodeErrorZ read(byte[] ser) {
125                 long ret = bindings.Retry_read(InternalUtils.encodeUint8Array(ser));
126                 GC.KeepAlive(ser);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 Result_RetryDecodeErrorZ ret_hu_conv = Result_RetryDecodeErrorZ.constr_from_ptr(ret);
129                 return ret_hu_conv;
130         }
131
132 }
133 } } }