[C#] Update auto-generated files
[ldk-java] / c_sharp / src / org / ldk / structs / PositiveTimestamp.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  * A timestamp that refers to a date after 1 January 1970.
11  * 
12  * # Invariants
13  * 
14  * The Unix timestamp representing the stored time has to be positive and no greater than
15  * [`MAX_TIMESTAMP`].
16  */
17 public class PositiveTimestamp : CommonBase {
18         internal PositiveTimestamp(object _dummy, long ptr) : base(ptr) { }
19         ~PositiveTimestamp() {
20                 if (ptr != 0) { bindings.PositiveTimestamp_free(ptr); }
21         }
22
23         /**
24          * Checks if two PositiveTimestamps contain equal inner contents.
25          * This ignores pointers and is_owned flags and looks at the values in fields.
26          * Two objects with NULL inner values will be considered "equal" here.
27          */
28         public bool eq(org.ldk.structs.PositiveTimestamp b) {
29                 bool ret = bindings.PositiveTimestamp_eq(this.ptr, b == null ? 0 : b.ptr);
30                 GC.KeepAlive(this);
31                 GC.KeepAlive(b);
32                 if (this != null) { this.ptrs_to.AddLast(b); };
33                 return ret;
34         }
35
36         public override bool Equals(object o) {
37                 if (!(o is PositiveTimestamp)) return false;
38                 return this.eq((PositiveTimestamp)o);
39         }
40         internal long clone_ptr() {
41                 long ret = bindings.PositiveTimestamp_clone_ptr(this.ptr);
42                 GC.KeepAlive(this);
43                 return ret;
44         }
45
46         /**
47          * Creates a copy of the PositiveTimestamp
48          */
49         public PositiveTimestamp clone() {
50                 long ret = bindings.PositiveTimestamp_clone(this.ptr);
51                 GC.KeepAlive(this);
52                 if (ret >= 0 && ret <= 4096) { return null; }
53                 org.ldk.structs.PositiveTimestamp ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PositiveTimestamp(null, ret); }
54                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
55                 return ret_hu_conv;
56         }
57
58         /**
59          * Generates a non-cryptographic 64-bit hash of the PositiveTimestamp.
60          */
61         public long hash() {
62                 long ret = bindings.PositiveTimestamp_hash(this.ptr);
63                 GC.KeepAlive(this);
64                 return ret;
65         }
66
67         public override int GetHashCode() {
68                 return (int)this.hash();
69         }
70         /**
71          * Creates a `PositiveTimestamp` from a Unix timestamp in the range `0..=MAX_TIMESTAMP`.
72          * 
73          * Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
74          */
75         public static Result_PositiveTimestampCreationErrorZ from_unix_timestamp(long unix_seconds) {
76                 long ret = bindings.PositiveTimestamp_from_unix_timestamp(unix_seconds);
77                 GC.KeepAlive(unix_seconds);
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
80                 return ret_hu_conv;
81         }
82
83         /**
84          * Creates a `PositiveTimestamp` from a [`SystemTime`] with a corresponding Unix timestamp in
85          * the range `0..=MAX_TIMESTAMP`.
86          * 
87          * Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices.
88          * 
89          * Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
90          */
91         public static Result_PositiveTimestampCreationErrorZ from_system_time(long time) {
92                 long ret = bindings.PositiveTimestamp_from_system_time(time);
93                 GC.KeepAlive(time);
94                 if (ret >= 0 && ret <= 4096) { return null; }
95                 Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
96                 return ret_hu_conv;
97         }
98
99         /**
100          * Creates a `PositiveTimestamp` from a [`Duration`] since the Unix epoch in the range
101          * `0..=MAX_TIMESTAMP`.
102          * 
103          * Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices.
104          * 
105          * Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
106          */
107         public static Result_PositiveTimestampCreationErrorZ from_duration_since_epoch(long duration) {
108                 long ret = bindings.PositiveTimestamp_from_duration_since_epoch(duration);
109                 GC.KeepAlive(duration);
110                 if (ret >= 0 && ret <= 4096) { return null; }
111                 Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
112                 return ret_hu_conv;
113         }
114
115         /**
116          * Returns the Unix timestamp representing the stored time
117          */
118         public long as_unix_timestamp() {
119                 long ret = bindings.PositiveTimestamp_as_unix_timestamp(this.ptr);
120                 GC.KeepAlive(this);
121                 return ret;
122         }
123
124         /**
125          * Returns the duration of the stored time since the Unix epoch
126          */
127         public long as_duration_since_epoch() {
128                 long ret = bindings.PositiveTimestamp_as_duration_since_epoch(this.ptr);
129                 GC.KeepAlive(this);
130                 return ret;
131         }
132
133         /**
134          * Returns the [`SystemTime`] representing the stored time
135          */
136         public long as_time() {
137                 long ret = bindings.PositiveTimestamp_as_time(this.ptr);
138                 GC.KeepAlive(this);
139                 return ret;
140         }
141
142 }
143 } } }