aa7882cd4abd5ec1a9efd80f4caacbc78e4e24b9
[ldk-java] / c_sharp / src / org / ldk / structs / WarningMessage.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * A warning message to be sent or received from a peer
11  */
12 public class WarningMessage : CommonBase {
13         internal WarningMessage(object _dummy, long ptr) : base(ptr) { }
14         ~WarningMessage() {
15                 if (ptr != 0) { bindings.WarningMessage_free(ptr); }
16         }
17
18         /**
19          * The channel ID involved in the warning.
20          * 
21          * All-0s indicates a warning unrelated to a specific channel.
22          */
23         public byte[] get_channel_id() {
24                 byte[] ret = bindings.WarningMessage_get_channel_id(this.ptr);
25                 GC.KeepAlive(this);
26                 return ret;
27         }
28
29         /**
30          * The channel ID involved in the warning.
31          * 
32          * All-0s indicates a warning unrelated to a specific channel.
33          */
34         public void set_channel_id(byte[] val) {
35                 bindings.WarningMessage_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38         }
39
40         /**
41          * A possibly human-readable warning description.
42          * The string should be sanitized before it is used (e.g. emitted to logs or printed to
43          * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
44          * the terminal emulator or the logging subsystem.
45          */
46         public string get_data() {
47                 string ret = bindings.WarningMessage_get_data(this.ptr);
48                 GC.KeepAlive(this);
49                 return ret;
50         }
51
52         /**
53          * A possibly human-readable warning description.
54          * The string should be sanitized before it is used (e.g. emitted to logs or printed to
55          * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
56          * the terminal emulator or the logging subsystem.
57          */
58         public void set_data(string val) {
59                 bindings.WarningMessage_set_data(this.ptr, val);
60                 GC.KeepAlive(this);
61                 GC.KeepAlive(val);
62         }
63
64         /**
65          * Constructs a new WarningMessage given each field
66          */
67         public static WarningMessage of(byte[] channel_id_arg, string data_arg) {
68                 long ret = bindings.WarningMessage_new(InternalUtils.check_arr_len(channel_id_arg, 32), data_arg);
69                 GC.KeepAlive(channel_id_arg);
70                 GC.KeepAlive(data_arg);
71                 if (ret >= 0 && ret <= 4096) { return null; }
72                 org.ldk.structs.WarningMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WarningMessage(null, ret); }
73                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
74                 return ret_hu_conv;
75         }
76
77         internal long clone_ptr() {
78                 long ret = bindings.WarningMessage_clone_ptr(this.ptr);
79                 GC.KeepAlive(this);
80                 return ret;
81         }
82
83         /**
84          * Creates a copy of the WarningMessage
85          */
86         public WarningMessage clone() {
87                 long ret = bindings.WarningMessage_clone(this.ptr);
88                 GC.KeepAlive(this);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 org.ldk.structs.WarningMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WarningMessage(null, ret); }
91                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
92                 return ret_hu_conv;
93         }
94
95         /**
96          * Checks if two WarningMessages contain equal inner contents.
97          * This ignores pointers and is_owned flags and looks at the values in fields.
98          * Two objects with NULL inner values will be considered "equal" here.
99          */
100         public bool eq(org.ldk.structs.WarningMessage b) {
101                 bool ret = bindings.WarningMessage_eq(this.ptr, b == null ? 0 : b.ptr);
102                 GC.KeepAlive(this);
103                 GC.KeepAlive(b);
104                 if (this != null) { this.ptrs_to.AddLast(b); };
105                 return ret;
106         }
107
108         public override bool Equals(object o) {
109                 if (!(o is WarningMessage)) return false;
110                 return this.eq((WarningMessage)o);
111         }
112         /**
113          * Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
114          */
115         public byte[] write() {
116                 byte[] ret = bindings.WarningMessage_write(this.ptr);
117                 GC.KeepAlive(this);
118                 return ret;
119         }
120
121         /**
122          * Read a WarningMessage from a byte array, created by WarningMessage_write
123          */
124         public static Result_WarningMessageDecodeErrorZ read(byte[] ser) {
125                 long ret = bindings.WarningMessage_read(ser);
126                 GC.KeepAlive(ser);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 Result_WarningMessageDecodeErrorZ ret_hu_conv = Result_WarningMessageDecodeErrorZ.constr_from_ptr(ret);
129                 return ret_hu_conv;
130         }
131
132 }
133 } } }