Merge pull request #146 from TheBlueMatt/main
[ldk-java] / src / main / java / org / ldk / structs / Hostname.java
index 1b49b1705cf9048c5e7484afa2392a43c83d6a64..a6d90d2c67a6b3f9c3dd32048ad77c7b11f98df7 100644 (file)
@@ -44,6 +44,18 @@ public class Hostname extends CommonBase {
                return ret_hu_conv;
        }
 
+       /**
+        * Generates a non-cryptographic 64-bit hash of the Hostname.
+        */
+       public long hash() {
+               long ret = bindings.Hostname_hash(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
+       @Override public int hashCode() {
+               return (int)this.hash();
+       }
        /**
         * Checks if two Hostnames contain equal inner contents.
         * This ignores pointers and is_owned flags and looks at the values in fields.
@@ -70,4 +82,24 @@ public class Hostname extends CommonBase {
                return ret;
        }
 
+       /**
+        * Serialize the Hostname object into a byte array which can be read by Hostname_read
+        */
+       public byte[] write() {
+               byte[] ret = bindings.Hostname_write(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
+       /**
+        * Read a Hostname from a byte array, created by Hostname_write
+        */
+       public static Result_HostnameDecodeErrorZ read(byte[] ser) {
+               long ret = bindings.Hostname_read(ser);
+               Reference.reachabilityFence(ser);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_HostnameDecodeErrorZ ret_hu_conv = Result_HostnameDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
 }