Update auto-generated bindings to 0.0.103
[ldk-java] / src / main / java / org / ldk / structs / Ping.java
index 860b2abe4e25f4b2d61d30dcfc9fd9469654756a..4ef0ce5f7166be7a42b8a237f478e99c69dbcf23 100644 (file)
@@ -2,40 +2,93 @@ package org.ldk.structs;
 
 import org.ldk.impl.bindings;
 import org.ldk.enums.*;
+import org.ldk.util.*;
+import java.util.Arrays;
+import javax.annotation.Nullable;
 
+
+/**
+ * A ping message to be sent or received from a peer
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
 public class Ping extends CommonBase {
        Ping(Object _dummy, long ptr) { super(ptr); }
        @Override @SuppressWarnings("deprecation")
        protected void finalize() throws Throwable {
-               bindings.Ping_free(ptr); super.finalize();
+               super.finalize();
+               if (ptr != 0) { bindings.Ping_free(ptr); }
        }
 
-       public short get_ponglen(Ping this_ptr) {
-               short ret = bindings.Ping_get_ponglen(this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * The desired response length
+        */
+       public short get_ponglen() {
+               short ret = bindings.Ping_get_ponglen(this.ptr);
                return ret;
        }
 
-       public void set_ponglen(Ping this_ptr, short val) {
-               bindings.Ping_set_ponglen(this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * The desired response length
+        */
+       public void set_ponglen(short val) {
+               bindings.Ping_set_ponglen(this.ptr, val);
        }
 
-       public short get_byteslen(Ping this_ptr) {
-               short ret = bindings.Ping_get_byteslen(this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * The ping packet size.
+        * This field is not sent on the wire. byteslen zeros are sent.
+        */
+       public short get_byteslen() {
+               short ret = bindings.Ping_get_byteslen(this.ptr);
                return ret;
        }
 
-       public void set_byteslen(Ping this_ptr, short val) {
-               bindings.Ping_set_byteslen(this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * The ping packet size.
+        * This field is not sent on the wire. byteslen zeros are sent.
+        */
+       public void set_byteslen(short val) {
+               bindings.Ping_set_byteslen(this.ptr, val);
+       }
+
+       /**
+        * Constructs a new Ping given each field
+        */
+       public static Ping of(short ponglen_arg, short byteslen_arg) {
+               long ret = bindings.Ping_new(ponglen_arg, byteslen_arg);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Ping ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Ping(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a copy of the Ping
+        */
+       public Ping clone() {
+               long ret = bindings.Ping_clone(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Ping ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Ping(null, ret); }
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Serialize the Ping object into a byte array which can be read by Ping_read
+        */
+       public byte[] write() {
+               byte[] ret = bindings.Ping_write(this.ptr);
+               return ret;
        }
 
-       public Ping(short ponglen_arg, short byteslen_arg) {
-               super(bindings.Ping_new(ponglen_arg, byteslen_arg));
+       /**
+        * Read a Ping from a byte array, created by Ping_write
+        */
+       public static Result_PingDecodeErrorZ read(byte[] ser) {
+               long ret = bindings.Ping_read(ser);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_PingDecodeErrorZ ret_hu_conv = Result_PingDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
        }
 
-       // Skipped Ping_write
-       // Skipped Ping_read
 }