1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * An init message to be sent or received from a peer
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class Init extends CommonBase {
15 Init(Object _dummy, long ptr) { super(ptr); }
16 @Override @SuppressWarnings("deprecation")
17 protected void finalize() throws Throwable {
19 if (ptr != 0) { bindings.Init_free(ptr); }
23 * The relevant features which the sender supports
25 public InitFeatures get_features() {
26 long ret = bindings.Init_get_features(this.ptr);
27 if (ret < 1024) { return null; }
28 InitFeatures ret_hu_conv = new InitFeatures(null, ret);
29 ret_hu_conv.ptrs_to.add(this);
34 * The relevant features which the sender supports
36 public void set_features(InitFeatures val) {
37 bindings.Init_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
41 * Constructs a new Init given each field
43 public static Init of(InitFeatures features_arg) {
44 long ret = bindings.Init_new(features_arg == null ? 0 : features_arg.ptr & ~1);
45 if (ret < 1024) { return null; }
46 Init ret_hu_conv = new Init(null, ret);
47 ret_hu_conv.ptrs_to.add(ret_hu_conv);
52 * Creates a copy of the Init
55 long ret = bindings.Init_clone(this.ptr);
56 if (ret < 1024) { return null; }
57 Init ret_hu_conv = new Init(null, ret);
58 ret_hu_conv.ptrs_to.add(this);
63 * Serialize the Init object into a byte array which can be read by Init_read
65 public byte[] write() {
66 byte[] ret = bindings.Init_write(this.ptr);
71 * Read a Init from a byte array, created by Init_write
73 public static Result_InitDecodeErrorZ read(byte[] ser) {
74 long ret = bindings.Init_read(ser);
75 if (ret < 1024) { return null; }
76 Result_InitDecodeErrorZ ret_hu_conv = Result_InitDecodeErrorZ.constr_from_ptr(ret);