1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A ping message to be sent or received from a peer
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Ping extends CommonBase {
16 Ping(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.Ping_free(ptr); }
24 * The desired response length
26 public short get_ponglen() {
27 short ret = bindings.Ping_get_ponglen(this.ptr);
28 Reference.reachabilityFence(this);
33 * The desired response length
35 public void set_ponglen(short val) {
36 bindings.Ping_set_ponglen(this.ptr, val);
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * The ping packet size.
43 * This field is not sent on the wire. byteslen zeros are sent.
45 public short get_byteslen() {
46 short ret = bindings.Ping_get_byteslen(this.ptr);
47 Reference.reachabilityFence(this);
52 * The ping packet size.
53 * This field is not sent on the wire. byteslen zeros are sent.
55 public void set_byteslen(short val) {
56 bindings.Ping_set_byteslen(this.ptr, val);
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * Constructs a new Ping given each field
64 public static Ping of(short ponglen_arg, short byteslen_arg) {
65 long ret = bindings.Ping_new(ponglen_arg, byteslen_arg);
66 Reference.reachabilityFence(ponglen_arg);
67 Reference.reachabilityFence(byteslen_arg);
68 if (ret >= 0 && ret <= 4096) { return null; }
69 org.ldk.structs.Ping ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Ping(null, ret); }
70 ret_hu_conv.ptrs_to.add(ret_hu_conv);
75 long ret = bindings.Ping_clone_ptr(this.ptr);
76 Reference.reachabilityFence(this);
81 * Creates a copy of the Ping
84 long ret = bindings.Ping_clone(this.ptr);
85 Reference.reachabilityFence(this);
86 if (ret >= 0 && ret <= 4096) { return null; }
87 org.ldk.structs.Ping ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Ping(null, ret); }
88 ret_hu_conv.ptrs_to.add(this);
93 * Serialize the Ping object into a byte array which can be read by Ping_read
95 public byte[] write() {
96 byte[] ret = bindings.Ping_write(this.ptr);
97 Reference.reachabilityFence(this);
102 * Read a Ping from a byte array, created by Ping_write
104 public static Result_PingDecodeErrorZ read(byte[] ser) {
105 long ret = bindings.Ping_read(ser);
106 Reference.reachabilityFence(ser);
107 if (ret >= 0 && ret <= 4096) { return null; }
108 Result_PingDecodeErrorZ ret_hu_conv = Result_PingDecodeErrorZ.constr_from_ptr(ret);