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 * An init message to be sent or received from a peer
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Init extends CommonBase {
16 Init(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.Init_free(ptr); }
24 * The relevant features which the sender supports
26 public InitFeatures get_features() {
27 long ret = bindings.Init_get_features(this.ptr);
28 Reference.reachabilityFence(this);
29 if (ret >= 0 && ret <= 4096) { return null; }
30 InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InitFeatures(null, ret); }
31 ret_hu_conv.ptrs_to.add(this);
36 * The relevant features which the sender supports
38 public void set_features(InitFeatures val) {
39 bindings.Init_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
40 Reference.reachabilityFence(this);
41 Reference.reachabilityFence(val);
45 * Constructs a new Init given each field
47 public static Init of(InitFeatures features_arg) {
48 long ret = bindings.Init_new(features_arg == null ? 0 : features_arg.ptr & ~1);
49 Reference.reachabilityFence(features_arg);
50 if (ret >= 0 && ret <= 4096) { return null; }
51 Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Init(null, ret); }
52 ret_hu_conv.ptrs_to.add(ret_hu_conv);
57 long ret = bindings.Init_clone_ptr(this.ptr);
58 Reference.reachabilityFence(this);
63 * Creates a copy of the Init
66 long ret = bindings.Init_clone(this.ptr);
67 Reference.reachabilityFence(this);
68 if (ret >= 0 && ret <= 4096) { return null; }
69 Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Init(null, ret); }
70 ret_hu_conv.ptrs_to.add(this);
75 * Serialize the Init object into a byte array which can be read by Init_read
77 public byte[] write() {
78 byte[] ret = bindings.Init_write(this.ptr);
79 Reference.reachabilityFence(this);
84 * Read a Init from a byte array, created by Init_write
86 public static Result_InitDecodeErrorZ read(byte[] ser) {
87 long ret = bindings.Init_read(ser);
88 Reference.reachabilityFence(ser);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 Result_InitDecodeErrorZ ret_hu_conv = Result_InitDecodeErrorZ.constr_from_ptr(ret);