[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / ExpiryTime.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 /**
10  * Positive duration that defines when (relatively to the timestamp) in the future the invoice
11  * expires
12  */
13 public class ExpiryTime : CommonBase {
14         internal ExpiryTime(object _dummy, long ptr) : base(ptr) { }
15         ~ExpiryTime() {
16                 if (ptr != 0) { bindings.ExpiryTime_free(ptr); }
17         }
18
19         internal long clone_ptr() {
20                 long ret = bindings.ExpiryTime_clone_ptr(this.ptr);
21                 GC.KeepAlive(this);
22                 return ret;
23         }
24
25         /**
26          * Creates a copy of the ExpiryTime
27          */
28         public ExpiryTime clone() {
29                 long ret = bindings.ExpiryTime_clone(this.ptr);
30                 GC.KeepAlive(this);
31                 if (ret >= 0 && ret <= 4096) { return null; }
32                 org.ldk.structs.ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ExpiryTime(null, ret); }
33                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
34                 return ret_hu_conv;
35         }
36
37         /**
38          * Generates a non-cryptographic 64-bit hash of the ExpiryTime.
39          */
40         public long hash() {
41                 long ret = bindings.ExpiryTime_hash(this.ptr);
42                 GC.KeepAlive(this);
43                 return ret;
44         }
45
46         public override int GetHashCode() {
47                 return (int)this.hash();
48         }
49         /**
50          * Checks if two ExpiryTimes contain equal inner contents.
51          * This ignores pointers and is_owned flags and looks at the values in fields.
52          * Two objects with NULL inner values will be considered "equal" here.
53          */
54         public bool eq(org.ldk.structs.ExpiryTime b) {
55                 bool ret = bindings.ExpiryTime_eq(this.ptr, b.ptr);
56                 GC.KeepAlive(this);
57                 GC.KeepAlive(b);
58                 if (this != null) { this.ptrs_to.AddLast(b); };
59                 return ret;
60         }
61
62         public override bool Equals(object o) {
63                 if (!(o is ExpiryTime)) return false;
64                 return this.eq((ExpiryTime)o);
65         }
66         /**
67          * Construct an `ExpiryTime` from seconds.
68          */
69         public static ExpiryTime from_seconds(long seconds) {
70                 long ret = bindings.ExpiryTime_from_seconds(seconds);
71                 GC.KeepAlive(seconds);
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 org.ldk.structs.ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ExpiryTime(null, ret); }
74                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
75                 return ret_hu_conv;
76         }
77
78         /**
79          * Construct an `ExpiryTime` from a [`Duration`], dropping the sub-second part.
80          */
81         public static ExpiryTime from_duration(long duration) {
82                 long ret = bindings.ExpiryTime_from_duration(duration);
83                 GC.KeepAlive(duration);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 org.ldk.structs.ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ExpiryTime(null, ret); }
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
87                 return ret_hu_conv;
88         }
89
90         /**
91          * Returns the expiry time in seconds
92          */
93         public long as_seconds() {
94                 long ret = bindings.ExpiryTime_as_seconds(this.ptr);
95                 GC.KeepAlive(this);
96                 return ret;
97         }
98
99         /**
100          * Returns a reference to the underlying [`Duration`] (=expiry time)
101          */
102         public long as_duration() {
103                 long ret = bindings.ExpiryTime_as_duration(this.ptr);
104                 GC.KeepAlive(this);
105                 return ret;
106         }
107
108 }
109 } } }