1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
10 * A ping message to be sent or received from a peer
12 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
13 public class Ping extends CommonBase {
14 Ping(Object _dummy, long ptr) { super(ptr); }
15 @Override @SuppressWarnings("deprecation")
16 protected void finalize() throws Throwable {
18 if (ptr != 0) { bindings.Ping_free(ptr); }
22 * The desired response length
24 public short get_ponglen() {
25 short ret = bindings.Ping_get_ponglen(this.ptr);
30 * The desired response length
32 public void set_ponglen(short val) {
33 bindings.Ping_set_ponglen(this.ptr, val);
37 * The ping packet size.
38 * This field is not sent on the wire. byteslen zeros are sent.
40 public short get_byteslen() {
41 short ret = bindings.Ping_get_byteslen(this.ptr);
46 * The ping packet size.
47 * This field is not sent on the wire. byteslen zeros are sent.
49 public void set_byteslen(short val) {
50 bindings.Ping_set_byteslen(this.ptr, val);
54 * Constructs a new Ping given each field
56 public static Ping of(short ponglen_arg, short byteslen_arg) {
57 long ret = bindings.Ping_new(ponglen_arg, byteslen_arg);
58 if (ret < 1024) { return null; }
59 Ping ret_hu_conv = new Ping(null, ret);
60 ret_hu_conv.ptrs_to.add(ret_hu_conv);
65 * Creates a copy of the Ping
68 long ret = bindings.Ping_clone(this.ptr);
69 if (ret < 1024) { return null; }
70 Ping ret_hu_conv = new Ping(null, ret);
71 ret_hu_conv.ptrs_to.add(this);
76 * Serialize the Ping object into a byte array which can be read by Ping_read
78 public byte[] write() {
79 byte[] ret = bindings.Ping_write(this.ptr);
84 * Read a Ping from a byte array, created by Ping_write
86 public static Result_PingDecodeErrorZ read(byte[] ser) {
87 long ret = bindings.Ping_read(ser);
88 if (ret < 1024) { return null; }
89 Result_PingDecodeErrorZ ret_hu_conv = Result_PingDecodeErrorZ.constr_from_ptr(ret);