Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / Init.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
8
9 /**
10  * An init message to be sent or received from a peer
11  */
12 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
13 public class Init extends CommonBase {
14         Init(Object _dummy, long ptr) { super(ptr); }
15         @Override @SuppressWarnings("deprecation")
16         protected void finalize() throws Throwable {
17                 super.finalize();
18                 if (ptr != 0) { bindings.Init_free(ptr); }
19         }
20
21         /**
22          * The relevant features which the sender supports
23          */
24         public InitFeatures get_features() {
25                 long ret = bindings.Init_get_features(this.ptr);
26                 if (ret < 1024) { return null; }
27                 InitFeatures ret_hu_conv = new InitFeatures(null, ret);
28                 ret_hu_conv.ptrs_to.add(this);
29                 return ret_hu_conv;
30         }
31
32         /**
33          * The relevant features which the sender supports
34          */
35         public void set_features(InitFeatures val) {
36                 bindings.Init_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
37                 this.ptrs_to.add(val);
38         }
39
40         /**
41          * Constructs a new Init given each field
42          */
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);
48                 ret_hu_conv.ptrs_to.add(features_arg);
49                 return ret_hu_conv;
50         }
51
52         /**
53          * Creates a copy of the Init
54          */
55         public Init clone() {
56                 long ret = bindings.Init_clone(this.ptr);
57                 if (ret < 1024) { return null; }
58                 Init ret_hu_conv = new Init(null, ret);
59                 ret_hu_conv.ptrs_to.add(this);
60                 return ret_hu_conv;
61         }
62
63         /**
64          * Serialize the Init object into a byte array which can be read by Init_read
65          */
66         public byte[] write() {
67                 byte[] ret = bindings.Init_write(this.ptr);
68                 return ret;
69         }
70
71         /**
72          * Read a Init from a byte array, created by Init_write
73          */
74         public static Result_InitDecodeErrorZ read(byte[] ser) {
75                 long ret = bindings.Init_read(ser);
76                 if (ret < 1024) { return null; }
77                 Result_InitDecodeErrorZ ret_hu_conv = Result_InitDecodeErrorZ.constr_from_ptr(ret);
78                 return ret_hu_conv;
79         }
80
81 }