2107295013dac2c8a6cce5c325fdad4d7831c14e
[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_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);
26                         default:
27                                 throw new ArgumentException("Impossible enum variant");
28                 }
29         }
30
31         /** A ErrorAction of type DisconnectPeer */
32         public class ErrorAction_DisconnectPeer : ErrorAction {
33                 /**
34                  * An error message which we should make an effort to send before we disconnect.
35                  * 
36                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
37                  */
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;
44                 }
45         }
46         /** A ErrorAction of type IgnoreError */
47         public class ErrorAction_IgnoreError : ErrorAction {
48                 internal ErrorAction_IgnoreError(long ptr) : base(null, ptr) {
49                 }
50         }
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);
56                 }
57         }
58         /** A ErrorAction of type IgnoreDuplicateGossip */
59         public class ErrorAction_IgnoreDuplicateGossip : ErrorAction {
60                 internal ErrorAction_IgnoreDuplicateGossip(long ptr) : base(null, ptr) {
61                 }
62         }
63         /** A ErrorAction of type SendErrorMessage */
64         public class ErrorAction_SendErrorMessage : ErrorAction {
65                 /**
66                  * The message to send.
67                  */
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;
74                 }
75         }
76         /** A ErrorAction of type SendWarningMessage */
77         public class ErrorAction_SendWarningMessage : ErrorAction {
78                 /**
79                  * The message to send.
80                  */
81                 public WarningMessage msg;
82                 /**
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.
86                  */
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);
94                 }
95         }
96         internal long clone_ptr() {
97                 long ret = bindings.ErrorAction_clone_ptr(this.ptr);
98                 GC.KeepAlive(this);
99                 return ret;
100         }
101
102         /**
103          * Creates a copy of the ErrorAction
104          */
105         public ErrorAction clone() {
106                 long ret = bindings.ErrorAction_clone(this.ptr);
107                 GC.KeepAlive(this);
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); };
111                 return ret_hu_conv;
112         }
113
114         /**
115          * Utility method to constructs a new DisconnectPeer-variant ErrorAction
116          */
117         public static ErrorAction disconnect_peer(org.ldk.structs.ErrorMessage msg) {
118                 long ret = bindings.ErrorAction_disconnect_peer(msg == null ? 0 : msg.ptr);
119                 GC.KeepAlive(msg);
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); };
124                 return ret_hu_conv;
125         }
126
127         /**
128          * Utility method to constructs a new IgnoreError-variant ErrorAction
129          */
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); };
135                 return ret_hu_conv;
136         }
137
138         /**
139          * Utility method to constructs a new IgnoreAndLog-variant ErrorAction
140          */
141         public static ErrorAction ignore_and_log(Level a) {
142                 long ret = bindings.ErrorAction_ignore_and_log(a);
143                 GC.KeepAlive(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); };
147                 return ret_hu_conv;
148         }
149
150         /**
151          * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
152          */
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); };
158                 return ret_hu_conv;
159         }
160
161         /**
162          * Utility method to constructs a new SendErrorMessage-variant ErrorAction
163          */
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);
166                 GC.KeepAlive(msg);
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); };
171                 return ret_hu_conv;
172         }
173
174         /**
175          * Utility method to constructs a new SendWarningMessage-variant ErrorAction
176          */
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);
179                 GC.KeepAlive(msg);
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); };
185                 return ret_hu_conv;
186         }
187
188 }
189 } } }