[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Hostname.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  * Represents a hostname for serialization purposes.
11  * Only the character set and length will be validated.
12  * The character set consists of ASCII alphanumeric characters, hyphens, and periods.
13  * Its length is guaranteed to be representable by a single byte.
14  * This serialization is used by [`BOLT 7`] hostnames.
15  * 
16  * [`BOLT 7`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md
17  */
18 public class Hostname : CommonBase {
19         internal Hostname(object _dummy, long ptr) : base(ptr) { }
20         ~Hostname() {
21                 if (ptr != 0) { bindings.Hostname_free(ptr); }
22         }
23
24         internal long clone_ptr() {
25                 long ret = bindings.Hostname_clone_ptr(this.ptr);
26                 GC.KeepAlive(this);
27                 return ret;
28         }
29
30         /**
31          * Creates a copy of the Hostname
32          */
33         public Hostname clone() {
34                 long ret = bindings.Hostname_clone(this.ptr);
35                 GC.KeepAlive(this);
36                 if (ret >= 0 && ret <= 4096) { return null; }
37                 org.ldk.structs.Hostname ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Hostname(null, ret); }
38                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
39                 return ret_hu_conv;
40         }
41
42         /**
43          * Generates a non-cryptographic 64-bit hash of the Hostname.
44          */
45         public long hash() {
46                 long ret = bindings.Hostname_hash(this.ptr);
47                 GC.KeepAlive(this);
48                 return ret;
49         }
50
51         public override int GetHashCode() {
52                 return (int)this.hash();
53         }
54         /**
55          * Checks if two Hostnames contain equal inner contents.
56          * This ignores pointers and is_owned flags and looks at the values in fields.
57          * Two objects with NULL inner values will be considered "equal" here.
58          */
59         public bool eq(org.ldk.structs.Hostname b) {
60                 bool ret = bindings.Hostname_eq(this.ptr, b == null ? 0 : b.ptr);
61                 GC.KeepAlive(this);
62                 GC.KeepAlive(b);
63                 if (this != null) { this.ptrs_to.AddLast(b); };
64                 return ret;
65         }
66
67         public override bool Equals(object o) {
68                 if (!(o is Hostname)) return false;
69                 return this.eq((Hostname)o);
70         }
71         /**
72          * Returns the length of the hostname.
73          */
74         public byte len() {
75                 byte ret = bindings.Hostname_len(this.ptr);
76                 GC.KeepAlive(this);
77                 return ret;
78         }
79
80         /**
81          * Serialize the Hostname object into a byte array which can be read by Hostname_read
82          */
83         public byte[] write() {
84                 long ret = bindings.Hostname_write(this.ptr);
85                 GC.KeepAlive(this);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
88                 return ret_conv;
89         }
90
91         /**
92          * Read a Hostname from a byte array, created by Hostname_write
93          */
94         public static Result_HostnameDecodeErrorZ read(byte[] ser) {
95                 long ret = bindings.Hostname_read(InternalUtils.encodeUint8Array(ser));
96                 GC.KeepAlive(ser);
97                 if (ret >= 0 && ret <= 4096) { return null; }
98                 Result_HostnameDecodeErrorZ ret_hu_conv = Result_HostnameDecodeErrorZ.constr_from_ptr(ret);
99                 return ret_hu_conv;
100         }
101
102 }
103 } } }