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 org.ldk.structs.Pong ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Pong(null, ret); }
51 if (ret_hu_conv != null) { 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 org.ldk.structs.Pong ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Pong(null, ret); }
69 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
74 * Checks if two Pongs contain equal inner contents.
75 * This ignores pointers and is_owned flags and looks at the values in fields.
76 * Two objects with NULL inner values will be considered "equal" here.
78 public boolean eq(Pong b) {
79 boolean ret = bindings.Pong_eq(this.ptr, b == null ? 0 : b.ptr);
80 Reference.reachabilityFence(this);
81 Reference.reachabilityFence(b);
82 if (this != null) { this.ptrs_to.add(b); };
86 @Override public boolean equals(Object o) {
87 if (!(o instanceof Pong)) return false;
88 return this.eq((Pong)o);
91 * Serialize the Pong object into a byte array which can be read by Pong_read
93 public byte[] write() {
94 byte[] ret = bindings.Pong_write(this.ptr);
95 Reference.reachabilityFence(this);
100 * Read a Pong from a byte array, created by Pong_write
102 public static Result_PongDecodeErrorZ read(byte[] ser) {
103 long ret = bindings.Pong_read(ser);
104 Reference.reachabilityFence(ser);
105 if (ret >= 0 && ret <= 4096) { return null; }
106 Result_PongDecodeErrorZ ret_hu_conv = Result_PongDecodeErrorZ.constr_from_ptr(ret);