1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * A ping message to be sent or received from a peer
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class Ping extends CommonBase {
15 Ping(Object _dummy, long ptr) { super(ptr); }
16 @Override @SuppressWarnings("deprecation")
17 protected void finalize() throws Throwable {
19 if (ptr != 0) { bindings.Ping_free(ptr); }
23 * The desired response length
25 public short get_ponglen() {
26 short ret = bindings.Ping_get_ponglen(this.ptr);
31 * The desired response length
33 public void set_ponglen(short val) {
34 bindings.Ping_set_ponglen(this.ptr, val);
38 * The ping packet size.
39 * This field is not sent on the wire. byteslen zeros are sent.
41 public short get_byteslen() {
42 short ret = bindings.Ping_get_byteslen(this.ptr);
47 * The ping packet size.
48 * This field is not sent on the wire. byteslen zeros are sent.
50 public void set_byteslen(short val) {
51 bindings.Ping_set_byteslen(this.ptr, val);
55 * Constructs a new Ping given each field
57 public static Ping of(short ponglen_arg, short byteslen_arg) {
58 long ret = bindings.Ping_new(ponglen_arg, byteslen_arg);
59 if (ret < 1024) { return null; }
60 Ping ret_hu_conv = new Ping(null, ret);
61 ret_hu_conv.ptrs_to.add(ret_hu_conv);
66 * Creates a copy of the Ping
69 long ret = bindings.Ping_clone(this.ptr);
70 if (ret < 1024) { return null; }
71 Ping ret_hu_conv = new Ping(null, ret);
72 ret_hu_conv.ptrs_to.add(this);
77 * Serialize the Ping object into a byte array which can be read by Ping_read
79 public byte[] write() {
80 byte[] ret = bindings.Ping_write(this.ptr);
85 * Read a Ping from a byte array, created by Ping_write
87 public static Result_PingDecodeErrorZ read(byte[] ser) {
88 long ret = bindings.Ping_read(ser);
89 if (ret < 1024) { return null; }
90 Result_PingDecodeErrorZ ret_hu_conv = Result_PingDecodeErrorZ.constr_from_ptr(ret);