[Java] Update auto-generated bindings to 0.0.105.0
[ldk-java] / src / main / java / org / ldk / structs / ErrorMessage.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  * An error message to be sent or received from a peer
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ErrorMessage extends CommonBase {
16         ErrorMessage(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.ErrorMessage_free(ptr); }
21         }
22
23         /**
24          * The channel ID involved in the error.
25          * 
26          * All-0s indicates a general error unrelated to a specific channel, after which all channels
27          * with the sending peer should be closed.
28          */
29         public byte[] get_channel_id() {
30                 byte[] ret = bindings.ErrorMessage_get_channel_id(this.ptr);
31                 Reference.reachabilityFence(this);
32                 return ret;
33         }
34
35         /**
36          * The channel ID involved in the error.
37          * 
38          * All-0s indicates a general error unrelated to a specific channel, after which all channels
39          * with the sending peer should be closed.
40          */
41         public void set_channel_id(byte[] val) {
42                 bindings.ErrorMessage_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
43                 Reference.reachabilityFence(this);
44                 Reference.reachabilityFence(val);
45         }
46
47         /**
48          * A possibly human-readable error description.
49          * The string should be sanitized before it is used (e.g. emitted to logs or printed to
50          * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
51          * the terminal emulator or the logging subsystem.
52          */
53         public String get_data() {
54                 String ret = bindings.ErrorMessage_get_data(this.ptr);
55                 Reference.reachabilityFence(this);
56                 return ret;
57         }
58
59         /**
60          * A possibly human-readable error description.
61          * The string should be sanitized before it is used (e.g. emitted to logs or printed to
62          * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
63          * the terminal emulator or the logging subsystem.
64          */
65         public void set_data(java.lang.String val) {
66                 bindings.ErrorMessage_set_data(this.ptr, val);
67                 Reference.reachabilityFence(this);
68                 Reference.reachabilityFence(val);
69         }
70
71         /**
72          * Constructs a new ErrorMessage given each field
73          */
74         public static ErrorMessage of(byte[] channel_id_arg, java.lang.String data_arg) {
75                 long ret = bindings.ErrorMessage_new(InternalUtils.check_arr_len(channel_id_arg, 32), data_arg);
76                 Reference.reachabilityFence(channel_id_arg);
77                 Reference.reachabilityFence(data_arg);
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ErrorMessage(null, ret); }
80                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
81                 return ret_hu_conv;
82         }
83
84         long clone_ptr() {
85                 long ret = bindings.ErrorMessage_clone_ptr(this.ptr);
86                 Reference.reachabilityFence(this);
87                 return ret;
88         }
89
90         /**
91          * Creates a copy of the ErrorMessage
92          */
93         public ErrorMessage clone() {
94                 long ret = bindings.ErrorMessage_clone(this.ptr);
95                 Reference.reachabilityFence(this);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ErrorMessage(null, ret); }
98                 ret_hu_conv.ptrs_to.add(this);
99                 return ret_hu_conv;
100         }
101
102         /**
103          * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
104          */
105         public byte[] write() {
106                 byte[] ret = bindings.ErrorMessage_write(this.ptr);
107                 Reference.reachabilityFence(this);
108                 return ret;
109         }
110
111         /**
112          * Read a ErrorMessage from a byte array, created by ErrorMessage_write
113          */
114         public static Result_ErrorMessageDecodeErrorZ read(byte[] ser) {
115                 long ret = bindings.ErrorMessage_read(ser);
116                 Reference.reachabilityFence(ser);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 Result_ErrorMessageDecodeErrorZ ret_hu_conv = Result_ErrorMessageDecodeErrorZ.constr_from_ptr(ret);
119                 return ret_hu_conv;
120         }
121
122 }