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