6 namespace org { namespace ldk { namespace structs {
9 * Strategies available to retry payment path failures.
11 public class Retry : CommonBase {
12 protected Retry(object _dummy, long ptr) : base(ptr) { }
14 if (ptr != 0) { bindings.Retry_free(ptr); }
17 internal static Retry constr_from_ptr(long ptr) {
18 long raw_ty = bindings.LDKRetry_ty_from_ptr(ptr);
20 case 0: return new Retry_Attempts(ptr);
21 case 1: return new Retry_Timeout(ptr);
23 throw new ArgumentException("Impossible enum variant");
27 /** A Retry of type Attempts */
28 public class Retry_Attempts : Retry {
30 internal Retry_Attempts(long ptr) : base(null, ptr) {
31 this.attempts = bindings.LDKRetry_Attempts_get_attempts(ptr);
34 /** A Retry of type Timeout */
35 public class Retry_Timeout : Retry {
37 internal Retry_Timeout(long ptr) : base(null, ptr) {
38 this.timeout = bindings.LDKRetry_Timeout_get_timeout(ptr);
41 internal long clone_ptr() {
42 long ret = bindings.Retry_clone_ptr(this.ptr);
48 * Creates a copy of the Retry
50 public Retry clone() {
51 long ret = bindings.Retry_clone(this.ptr);
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); };
60 * Utility method to constructs a new Attempts-variant Retry
62 public static Retry attempts(int a) {
63 long ret = bindings.Retry_attempts(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); };
72 * Utility method to constructs a new Timeout-variant Retry
74 public static Retry timeout(long a) {
75 long ret = bindings.Retry_timeout(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); };
84 * Checks if two Retrys contain equal inner contents.
85 * This ignores pointers and is_owned flags and looks at the values in fields.
87 public bool eq(org.ldk.structs.Retry b) {
88 bool ret = bindings.Retry_eq(this.ptr, b.ptr);
94 public override bool Equals(object o) {
95 if (!(o is Retry)) return false;
96 return this.eq((Retry)o);
99 * Generates a non-cryptographic 64-bit hash of the Retry.
102 long ret = bindings.Retry_hash(this.ptr);
107 public override int GetHashCode() {
108 return (int)this.hash();
111 * Serialize the Retry object into a byte array which can be read by Retry_read
113 public byte[] write() {
114 long ret = bindings.Retry_write(this.ptr);
116 if (ret >= 0 && ret <= 4096) { return null; }
117 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
122 * Read a Retry from a byte array, created by Retry_write
124 public static Result_RetryDecodeErrorZ read(byte[] ser) {
125 long ret = bindings.Retry_read(InternalUtils.encodeUint8Array(ser));
127 if (ret >= 0 && ret <= 4096) { return null; }
128 Result_RetryDecodeErrorZ ret_hu_conv = Result_RetryDecodeErrorZ.constr_from_ptr(ret);