6 namespace org { namespace ldk { namespace structs {
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.
16 * [`BOLT 7`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md
18 public class Hostname : CommonBase {
19 internal Hostname(object _dummy, long ptr) : base(ptr) { }
21 if (ptr != 0) { bindings.Hostname_free(ptr); }
24 internal long clone_ptr() {
25 long ret = bindings.Hostname_clone_ptr(this.ptr);
31 * Creates a copy of the Hostname
33 public Hostname clone() {
34 long ret = bindings.Hostname_clone(this.ptr);
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); };
43 * Generates a non-cryptographic 64-bit hash of the Hostname.
46 long ret = bindings.Hostname_hash(this.ptr);
51 public override int GetHashCode() {
52 return (int)this.hash();
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.
59 public bool eq(org.ldk.structs.Hostname b) {
60 bool ret = bindings.Hostname_eq(this.ptr, b == null ? 0 : b.ptr);
63 if (this != null) { this.ptrs_to.AddLast(b); };
67 public override bool Equals(object o) {
68 if (!(o is Hostname)) return false;
69 return this.eq((Hostname)o);
72 * Returns the length of the hostname.
75 byte ret = bindings.Hostname_len(this.ptr);
81 * Serialize the Hostname object into a byte array which can be read by Hostname_read
83 public byte[] write() {
84 long ret = bindings.Hostname_write(this.ptr);
86 if (ret >= 0 && ret <= 4096) { return null; }
87 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
92 * Read a Hostname from a byte array, created by Hostname_write
94 public static Result_HostnameDecodeErrorZ read(byte[] ser) {
95 long ret = bindings.Hostname_read(InternalUtils.encodeUint8Array(ser));
97 if (ret >= 0 && ret <= 4096) { return null; }
98 Result_HostnameDecodeErrorZ ret_hu_conv = Result_HostnameDecodeErrorZ.constr_from_ptr(ret);