[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / ErrorAction.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  * Used to put an error message in a [`LightningError`].
10  */
11 public class ErrorAction : CommonBase {
12         protected ErrorAction(object _dummy, long ptr) : base(ptr) { }
13         ~ErrorAction() {
14                 if (ptr != 0) { bindings.ErrorAction_free(ptr); }
15         }
16
17         internal static ErrorAction constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKErrorAction_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new ErrorAction_DisconnectPeer(ptr);
21                         case 1: return new ErrorAction_DisconnectPeerWithWarning(ptr);
22                         case 2: return new ErrorAction_IgnoreError(ptr);
23                         case 3: return new ErrorAction_IgnoreAndLog(ptr);
24                         case 4: return new ErrorAction_IgnoreDuplicateGossip(ptr);
25                         case 5: return new ErrorAction_SendErrorMessage(ptr);
26                         case 6: return new ErrorAction_SendWarningMessage(ptr);
27                         default:
28                                 throw new ArgumentException("Impossible enum variant");
29                 }
30         }
31
32         /** A ErrorAction of type DisconnectPeer */
33         public class ErrorAction_DisconnectPeer : ErrorAction {
34                 /**
35                  * An error message which we should make an effort to send before we disconnect.
36                  * 
37                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
38                  */
39                 public ErrorMessage msg;
40                 internal ErrorAction_DisconnectPeer(long ptr) : base(null, ptr) {
41                         long msg = bindings.LDKErrorAction_DisconnectPeer_get_msg(ptr);
42                         org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); }
43                         if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.AddLast(this); };
44                         this.msg = msg_hu_conv;
45                 }
46         }
47         /** A ErrorAction of type DisconnectPeerWithWarning */
48         public class ErrorAction_DisconnectPeerWithWarning : ErrorAction {
49                 /**
50                  * A warning message which we should make an effort to send before we disconnect.
51                  */
52                 public WarningMessage msg;
53                 internal ErrorAction_DisconnectPeerWithWarning(long ptr) : base(null, ptr) {
54                         long msg = bindings.LDKErrorAction_DisconnectPeerWithWarning_get_msg(ptr);
55                         org.ldk.structs.WarningMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.WarningMessage(null, msg); }
56                         if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.AddLast(this); };
57                         this.msg = msg_hu_conv;
58                 }
59         }
60         /** A ErrorAction of type IgnoreError */
61         public class ErrorAction_IgnoreError : ErrorAction {
62                 internal ErrorAction_IgnoreError(long ptr) : base(null, ptr) {
63                 }
64         }
65         /** A ErrorAction of type IgnoreAndLog */
66         public class ErrorAction_IgnoreAndLog : ErrorAction {
67                 public Level ignore_and_log;
68                 internal ErrorAction_IgnoreAndLog(long ptr) : base(null, ptr) {
69                         this.ignore_and_log = bindings.LDKErrorAction_IgnoreAndLog_get_ignore_and_log(ptr);
70                 }
71         }
72         /** A ErrorAction of type IgnoreDuplicateGossip */
73         public class ErrorAction_IgnoreDuplicateGossip : ErrorAction {
74                 internal ErrorAction_IgnoreDuplicateGossip(long ptr) : base(null, ptr) {
75                 }
76         }
77         /** A ErrorAction of type SendErrorMessage */
78         public class ErrorAction_SendErrorMessage : ErrorAction {
79                 /**
80                  * The message to send.
81                  */
82                 public ErrorMessage msg;
83                 internal ErrorAction_SendErrorMessage(long ptr) : base(null, ptr) {
84                         long msg = bindings.LDKErrorAction_SendErrorMessage_get_msg(ptr);
85                         org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); }
86                         if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.AddLast(this); };
87                         this.msg = msg_hu_conv;
88                 }
89         }
90         /** A ErrorAction of type SendWarningMessage */
91         public class ErrorAction_SendWarningMessage : ErrorAction {
92                 /**
93                  * The message to send.
94                  */
95                 public WarningMessage msg;
96                 /**
97                  * The peer may have done something harmless that we weren't able to meaningfully process,
98                  * though we should still tell them about it.
99                  * If this event is logged, log it at the given level.
100                  */
101                 public Level log_level;
102                 internal ErrorAction_SendWarningMessage(long ptr) : base(null, ptr) {
103                         long msg = bindings.LDKErrorAction_SendWarningMessage_get_msg(ptr);
104                         org.ldk.structs.WarningMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.WarningMessage(null, msg); }
105                         if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.AddLast(this); };
106                         this.msg = msg_hu_conv;
107                         this.log_level = bindings.LDKErrorAction_SendWarningMessage_get_log_level(ptr);
108                 }
109         }
110         internal long clone_ptr() {
111                 long ret = bindings.ErrorAction_clone_ptr(this.ptr);
112                 GC.KeepAlive(this);
113                 return ret;
114         }
115
116         /**
117          * Creates a copy of the ErrorAction
118          */
119         public ErrorAction clone() {
120                 long ret = bindings.ErrorAction_clone(this.ptr);
121                 GC.KeepAlive(this);
122                 if (ret >= 0 && ret <= 4096) { return null; }
123                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
124                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
125                 return ret_hu_conv;
126         }
127
128         /**
129          * Utility method to constructs a new DisconnectPeer-variant ErrorAction
130          */
131         public static ErrorAction disconnect_peer(org.ldk.structs.ErrorMessage msg) {
132                 long ret = bindings.ErrorAction_disconnect_peer(msg == null ? 0 : msg.ptr);
133                 GC.KeepAlive(msg);
134                 if (ret >= 0 && ret <= 4096) { return null; }
135                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
136                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
137                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
138                 return ret_hu_conv;
139         }
140
141         /**
142          * Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction
143          */
144         public static ErrorAction disconnect_peer_with_warning(org.ldk.structs.WarningMessage msg) {
145                 long ret = bindings.ErrorAction_disconnect_peer_with_warning(msg == null ? 0 : msg.ptr);
146                 GC.KeepAlive(msg);
147                 if (ret >= 0 && ret <= 4096) { return null; }
148                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
149                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
150                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
151                 return ret_hu_conv;
152         }
153
154         /**
155          * Utility method to constructs a new IgnoreError-variant ErrorAction
156          */
157         public static ErrorAction ignore_error() {
158                 long ret = bindings.ErrorAction_ignore_error();
159                 if (ret >= 0 && ret <= 4096) { return null; }
160                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
161                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
162                 return ret_hu_conv;
163         }
164
165         /**
166          * Utility method to constructs a new IgnoreAndLog-variant ErrorAction
167          */
168         public static ErrorAction ignore_and_log(Level a) {
169                 long ret = bindings.ErrorAction_ignore_and_log(a);
170                 GC.KeepAlive(a);
171                 if (ret >= 0 && ret <= 4096) { return null; }
172                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
173                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
174                 return ret_hu_conv;
175         }
176
177         /**
178          * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
179          */
180         public static ErrorAction ignore_duplicate_gossip() {
181                 long ret = bindings.ErrorAction_ignore_duplicate_gossip();
182                 if (ret >= 0 && ret <= 4096) { return null; }
183                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
184                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
185                 return ret_hu_conv;
186         }
187
188         /**
189          * Utility method to constructs a new SendErrorMessage-variant ErrorAction
190          */
191         public static ErrorAction send_error_message(org.ldk.structs.ErrorMessage msg) {
192                 long ret = bindings.ErrorAction_send_error_message(msg == null ? 0 : msg.ptr);
193                 GC.KeepAlive(msg);
194                 if (ret >= 0 && ret <= 4096) { return null; }
195                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
196                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
197                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
198                 return ret_hu_conv;
199         }
200
201         /**
202          * Utility method to constructs a new SendWarningMessage-variant ErrorAction
203          */
204         public static ErrorAction send_warning_message(org.ldk.structs.WarningMessage msg, Level log_level) {
205                 long ret = bindings.ErrorAction_send_warning_message(msg == null ? 0 : msg.ptr, log_level);
206                 GC.KeepAlive(msg);
207                 GC.KeepAlive(log_level);
208                 if (ret >= 0 && ret <= 4096) { return null; }
209                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
210                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
211                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
212                 return ret_hu_conv;
213         }
214
215         /**
216          * Generates a non-cryptographic 64-bit hash of the ErrorAction.
217          */
218         public long hash() {
219                 long ret = bindings.ErrorAction_hash(this.ptr);
220                 GC.KeepAlive(this);
221                 return ret;
222         }
223
224         public override int GetHashCode() {
225                 return (int)this.hash();
226         }
227 }
228 } } }