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 pong message to be sent or received from a peer
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Pong extends CommonBase {
16 Pong(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.Pong_free(ptr); }
24 * The pong packet size.
25 * This field is not sent on the wire. byteslen zeros are sent.
27 public short get_byteslen() {
28 short ret = bindings.Pong_get_byteslen(this.ptr);
29 Reference.reachabilityFence(this);
34 * The pong packet size.
35 * This field is not sent on the wire. byteslen zeros are sent.
37 public void set_byteslen(short val) {
38 bindings.Pong_set_byteslen(this.ptr, val);
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * Constructs a new Pong given each field
46 public static Pong of(short byteslen_arg) {
47 long ret = bindings.Pong_new(byteslen_arg);
48 Reference.reachabilityFence(byteslen_arg);
49 if (ret >= 0 && ret <= 4096) { return null; }
50 Pong ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Pong(null, ret); }
51 ret_hu_conv.ptrs_to.add(ret_hu_conv);
56 long ret = bindings.Pong_clone_ptr(this.ptr);
57 Reference.reachabilityFence(this);
62 * Creates a copy of the Pong
65 long ret = bindings.Pong_clone(this.ptr);
66 Reference.reachabilityFence(this);
67 if (ret >= 0 && ret <= 4096) { return null; }
68 Pong ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Pong(null, ret); }
69 ret_hu_conv.ptrs_to.add(this);
74 * Serialize the Pong object into a byte array which can be read by Pong_read
76 public byte[] write() {
77 byte[] ret = bindings.Pong_write(this.ptr);
78 Reference.reachabilityFence(this);
83 * Read a Pong from a byte array, created by Pong_write
85 public static Result_PongDecodeErrorZ read(byte[] ser) {
86 long ret = bindings.Pong_read(ser);
87 Reference.reachabilityFence(ser);
88 if (ret >= 0 && ret <= 4096) { return null; }
89 Result_PongDecodeErrorZ ret_hu_conv = Result_PongDecodeErrorZ.constr_from_ptr(ret);