6 namespace org { namespace ldk { namespace structs {
9 * Used to put an error message in a LightningError
11 public class ErrorAction : CommonBase {
12 protected ErrorAction(object _dummy, long ptr) : base(ptr) { }
14 if (ptr != 0) { bindings.ErrorAction_free(ptr); }
17 internal static ErrorAction constr_from_ptr(long ptr) {
18 long raw_ty = bindings.LDKErrorAction_ty_from_ptr(ptr);
20 case 0: return new ErrorAction_DisconnectPeer(ptr);
21 case 1: return new ErrorAction_IgnoreError(ptr);
22 case 2: return new ErrorAction_IgnoreAndLog(ptr);
23 case 3: return new ErrorAction_IgnoreDuplicateGossip(ptr);
24 case 4: return new ErrorAction_SendErrorMessage(ptr);
25 case 5: return new ErrorAction_SendWarningMessage(ptr);
27 throw new ArgumentException("Impossible enum variant");
31 /** A ErrorAction of type DisconnectPeer */
32 public class ErrorAction_DisconnectPeer : ErrorAction {
34 * An error message which we should make an effort to send before we disconnect.
36 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
38 public ErrorMessage msg;
39 internal ErrorAction_DisconnectPeer(long ptr) : base(null, ptr) {
40 long msg = bindings.LDKErrorAction_DisconnectPeer_get_msg(ptr);
41 org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); }
42 if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.AddLast(this); };
43 this.msg = msg_hu_conv;
46 /** A ErrorAction of type IgnoreError */
47 public class ErrorAction_IgnoreError : ErrorAction {
48 internal ErrorAction_IgnoreError(long ptr) : base(null, ptr) {
51 /** A ErrorAction of type IgnoreAndLog */
52 public class ErrorAction_IgnoreAndLog : ErrorAction {
53 public Level ignore_and_log;
54 internal ErrorAction_IgnoreAndLog(long ptr) : base(null, ptr) {
55 this.ignore_and_log = bindings.LDKErrorAction_IgnoreAndLog_get_ignore_and_log(ptr);
58 /** A ErrorAction of type IgnoreDuplicateGossip */
59 public class ErrorAction_IgnoreDuplicateGossip : ErrorAction {
60 internal ErrorAction_IgnoreDuplicateGossip(long ptr) : base(null, ptr) {
63 /** A ErrorAction of type SendErrorMessage */
64 public class ErrorAction_SendErrorMessage : ErrorAction {
66 * The message to send.
68 public ErrorMessage msg;
69 internal ErrorAction_SendErrorMessage(long ptr) : base(null, ptr) {
70 long msg = bindings.LDKErrorAction_SendErrorMessage_get_msg(ptr);
71 org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); }
72 if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.AddLast(this); };
73 this.msg = msg_hu_conv;
76 /** A ErrorAction of type SendWarningMessage */
77 public class ErrorAction_SendWarningMessage : ErrorAction {
79 * The message to send.
81 public WarningMessage msg;
83 * The peer may have done something harmless that we weren't able to meaningfully process,
84 * though we should still tell them about it.
85 * If this event is logged, log it at the given level.
87 public Level log_level;
88 internal ErrorAction_SendWarningMessage(long ptr) : base(null, ptr) {
89 long msg = bindings.LDKErrorAction_SendWarningMessage_get_msg(ptr);
90 org.ldk.structs.WarningMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.WarningMessage(null, msg); }
91 if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.AddLast(this); };
92 this.msg = msg_hu_conv;
93 this.log_level = bindings.LDKErrorAction_SendWarningMessage_get_log_level(ptr);
96 internal long clone_ptr() {
97 long ret = bindings.ErrorAction_clone_ptr(this.ptr);
103 * Creates a copy of the ErrorAction
105 public ErrorAction clone() {
106 long ret = bindings.ErrorAction_clone(this.ptr);
108 if (ret >= 0 && ret <= 4096) { return null; }
109 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
110 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
115 * Utility method to constructs a new DisconnectPeer-variant ErrorAction
117 public static ErrorAction disconnect_peer(org.ldk.structs.ErrorMessage msg) {
118 long ret = bindings.ErrorAction_disconnect_peer(msg == null ? 0 : msg.ptr);
120 if (ret >= 0 && ret <= 4096) { return null; }
121 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
122 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
123 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
128 * Utility method to constructs a new IgnoreError-variant ErrorAction
130 public static ErrorAction ignore_error() {
131 long ret = bindings.ErrorAction_ignore_error();
132 if (ret >= 0 && ret <= 4096) { return null; }
133 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
134 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
139 * Utility method to constructs a new IgnoreAndLog-variant ErrorAction
141 public static ErrorAction ignore_and_log(Level a) {
142 long ret = bindings.ErrorAction_ignore_and_log(a);
144 if (ret >= 0 && ret <= 4096) { return null; }
145 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
146 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
151 * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
153 public static ErrorAction ignore_duplicate_gossip() {
154 long ret = bindings.ErrorAction_ignore_duplicate_gossip();
155 if (ret >= 0 && ret <= 4096) { return null; }
156 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
157 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
162 * Utility method to constructs a new SendErrorMessage-variant ErrorAction
164 public static ErrorAction send_error_message(org.ldk.structs.ErrorMessage msg) {
165 long ret = bindings.ErrorAction_send_error_message(msg == null ? 0 : msg.ptr);
167 if (ret >= 0 && ret <= 4096) { return null; }
168 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
169 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
170 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
175 * Utility method to constructs a new SendWarningMessage-variant ErrorAction
177 public static ErrorAction send_warning_message(org.ldk.structs.WarningMessage msg, Level log_level) {
178 long ret = bindings.ErrorAction_send_warning_message(msg == null ? 0 : msg.ptr, log_level);
180 GC.KeepAlive(log_level);
181 if (ret >= 0 && ret <= 4096) { return null; }
182 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
183 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
184 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };