Update auto-updated Java files
[ldk-java] / src / main / java / org / ldk / structs / Ping.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * A ping message to be sent or received from a peer
13  */
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 {
19                 super.finalize();
20                 if (ptr != 0) { bindings.Ping_free(ptr); }
21         }
22
23         /**
24          * The desired response length
25          */
26         public short get_ponglen() {
27                 short ret = bindings.Ping_get_ponglen(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * The desired response length
34          */
35         public void set_ponglen(short val) {
36                 bindings.Ping_set_ponglen(this.ptr, val);
37                 Reference.reachabilityFence(this);
38                 Reference.reachabilityFence(val);
39         }
40
41         /**
42          * The ping packet size.
43          * This field is not sent on the wire. byteslen zeros are sent.
44          */
45         public short get_byteslen() {
46                 short ret = bindings.Ping_get_byteslen(this.ptr);
47                 Reference.reachabilityFence(this);
48                 return ret;
49         }
50
51         /**
52          * The ping packet size.
53          * This field is not sent on the wire. byteslen zeros are sent.
54          */
55         public void set_byteslen(short val) {
56                 bindings.Ping_set_byteslen(this.ptr, val);
57                 Reference.reachabilityFence(this);
58                 Reference.reachabilityFence(val);
59         }
60
61         /**
62          * Constructs a new Ping given each field
63          */
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                 Ping ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Ping(null, ret); }
70                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
71                 return ret_hu_conv;
72         }
73
74         long clone_ptr() {
75                 long ret = bindings.Ping_clone_ptr(this.ptr);
76                 Reference.reachabilityFence(this);
77                 return ret;
78         }
79
80         /**
81          * Creates a copy of the Ping
82          */
83         public Ping clone() {
84                 long ret = bindings.Ping_clone(this.ptr);
85                 Reference.reachabilityFence(this);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 Ping ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Ping(null, ret); }
88                 ret_hu_conv.ptrs_to.add(this);
89                 return ret_hu_conv;
90         }
91
92         /**
93          * Serialize the Ping object into a byte array which can be read by Ping_read
94          */
95         public byte[] write() {
96                 byte[] ret = bindings.Ping_write(this.ptr);
97                 Reference.reachabilityFence(this);
98                 return ret;
99         }
100
101         /**
102          * Read a Ping from a byte array, created by Ping_write
103          */
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);
109                 return ret_hu_conv;
110         }
111
112 }