Merge pull request #124 from TheBlueMatt/main
[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 public class Hostname : CommonBase {
17         internal Hostname(object _dummy, long ptr) : base(ptr) { }
18         ~Hostname() {
19                 if (ptr != 0) { bindings.Hostname_free(ptr); }
20         }
21
22         internal long clone_ptr() {
23                 long ret = bindings.Hostname_clone_ptr(this.ptr);
24                 GC.KeepAlive(this);
25                 return ret;
26         }
27
28         /**
29          * Creates a copy of the Hostname
30          */
31         public Hostname clone() {
32                 long ret = bindings.Hostname_clone(this.ptr);
33                 GC.KeepAlive(this);
34                 if (ret >= 0 && ret <= 4096) { return null; }
35                 org.ldk.structs.Hostname ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Hostname(null, ret); }
36                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
37                 return ret_hu_conv;
38         }
39
40         /**
41          * Checks if two Hostnames contain equal inner contents.
42          * This ignores pointers and is_owned flags and looks at the values in fields.
43          * Two objects with NULL inner values will be considered "equal" here.
44          */
45         public bool eq(org.ldk.structs.Hostname b) {
46                 bool ret = bindings.Hostname_eq(this.ptr, b == null ? 0 : b.ptr);
47                 GC.KeepAlive(this);
48                 GC.KeepAlive(b);
49                 if (this != null) { this.ptrs_to.AddLast(b); };
50                 return ret;
51         }
52
53         public override bool Equals(object o) {
54                 if (!(o is Hostname)) return false;
55                 return this.eq((Hostname)o);
56         }
57         /**
58          * Returns the length of the hostname.
59          */
60         public byte len() {
61                 byte ret = bindings.Hostname_len(this.ptr);
62                 GC.KeepAlive(this);
63                 return ret;
64         }
65
66 }
67 } } }