[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Sha256.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  * SHA-256 hash
11  */
12 public class Sha256 : CommonBase {
13         internal Sha256(object _dummy, long ptr) : base(ptr) { }
14         ~Sha256() {
15                 if (ptr != 0) { bindings.Sha256_free(ptr); }
16         }
17
18         internal long clone_ptr() {
19                 long ret = bindings.Sha256_clone_ptr(this.ptr);
20                 GC.KeepAlive(this);
21                 return ret;
22         }
23
24         /**
25          * Creates a copy of the Sha256
26          */
27         public Sha256 clone() {
28                 long ret = bindings.Sha256_clone(this.ptr);
29                 GC.KeepAlive(this);
30                 if (ret >= 0 && ret <= 4096) { return null; }
31                 org.ldk.structs.Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Sha256(null, ret); }
32                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
33                 return ret_hu_conv;
34         }
35
36         /**
37          * Generates a non-cryptographic 64-bit hash of the Sha256.
38          */
39         public long hash() {
40                 long ret = bindings.Sha256_hash(this.ptr);
41                 GC.KeepAlive(this);
42                 return ret;
43         }
44
45         public override int GetHashCode() {
46                 return (int)this.hash();
47         }
48         /**
49          * Checks if two Sha256s contain equal inner contents.
50          * This ignores pointers and is_owned flags and looks at the values in fields.
51          * Two objects with NULL inner values will be considered "equal" here.
52          */
53         public bool eq(org.ldk.structs.Sha256 b) {
54                 bool ret = bindings.Sha256_eq(this.ptr, b == null ? 0 : b.ptr);
55                 GC.KeepAlive(this);
56                 GC.KeepAlive(b);
57                 if (this != null) { this.ptrs_to.AddLast(b); };
58                 return ret;
59         }
60
61         public override bool Equals(object o) {
62                 if (!(o is Sha256)) return false;
63                 return this.eq((Sha256)o);
64         }
65         /**
66          * Constructs a new [`Sha256`] from the given bytes, which are assumed to be the output of a
67          * single sha256 hash.
68          */
69         public static Sha256 from_bytes(byte[] bytes) {
70                 long ret = bindings.Sha256_from_bytes(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(bytes, 32)));
71                 GC.KeepAlive(bytes);
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 org.ldk.structs.Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Sha256(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 } } }