764305da9313ffcabe180e5b0ad3d8cfb5111be4
[ldk-java] / c_sharp / src / org / ldk / structs / GraphSyncError.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  * All-encompassing standard error type that processing can return
10  */
11 public class GraphSyncError : CommonBase {
12         protected GraphSyncError(object _dummy, long ptr) : base(ptr) { }
13         ~GraphSyncError() {
14                 if (ptr != 0) { bindings.GraphSyncError_free(ptr); }
15         }
16
17         internal static GraphSyncError constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKGraphSyncError_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new GraphSyncError_DecodeError(ptr);
21                         case 1: return new GraphSyncError_LightningError(ptr);
22                         default:
23                                 throw new ArgumentException("Impossible enum variant");
24                 }
25         }
26
27         /** A GraphSyncError of type DecodeError */
28         public class GraphSyncError_DecodeError : GraphSyncError {
29                 public DecodeError decode_error;
30                 internal GraphSyncError_DecodeError(long ptr) : base(null, ptr) {
31                         long decode_error = bindings.LDKGraphSyncError_DecodeError_get_decode_error(ptr);
32                         org.ldk.structs.DecodeError decode_error_hu_conv = org.ldk.structs.DecodeError.constr_from_ptr(decode_error);
33                         if (decode_error_hu_conv != null) { decode_error_hu_conv.ptrs_to.AddLast(this); };
34                         this.decode_error = decode_error_hu_conv;
35                 }
36         }
37         /** A GraphSyncError of type LightningError */
38         public class GraphSyncError_LightningError : GraphSyncError {
39                 public LightningError lightning_error;
40                 internal GraphSyncError_LightningError(long ptr) : base(null, ptr) {
41                         long lightning_error = bindings.LDKGraphSyncError_LightningError_get_lightning_error(ptr);
42                         org.ldk.structs.LightningError lightning_error_hu_conv = null; if (lightning_error < 0 || lightning_error > 4096) { lightning_error_hu_conv = new org.ldk.structs.LightningError(null, lightning_error); }
43                         if (lightning_error_hu_conv != null) { lightning_error_hu_conv.ptrs_to.AddLast(this); };
44                         this.lightning_error = lightning_error_hu_conv;
45                 }
46         }
47         internal long clone_ptr() {
48                 long ret = bindings.GraphSyncError_clone_ptr(this.ptr);
49                 GC.KeepAlive(this);
50                 return ret;
51         }
52
53         /**
54          * Creates a copy of the GraphSyncError
55          */
56         public GraphSyncError clone() {
57                 long ret = bindings.GraphSyncError_clone(this.ptr);
58                 GC.KeepAlive(this);
59                 if (ret >= 0 && ret <= 4096) { return null; }
60                 org.ldk.structs.GraphSyncError ret_hu_conv = org.ldk.structs.GraphSyncError.constr_from_ptr(ret);
61                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
62                 return ret_hu_conv;
63         }
64
65         /**
66          * Utility method to constructs a new DecodeError-variant GraphSyncError
67          */
68         public static GraphSyncError decode_error(org.ldk.structs.DecodeError a) {
69                 long ret = bindings.GraphSyncError_decode_error(a.ptr);
70                 GC.KeepAlive(a);
71                 if (ret >= 0 && ret <= 4096) { return null; }
72                 org.ldk.structs.GraphSyncError ret_hu_conv = org.ldk.structs.GraphSyncError.constr_from_ptr(ret);
73                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
74                 return ret_hu_conv;
75         }
76
77         /**
78          * Utility method to constructs a new LightningError-variant GraphSyncError
79          */
80         public static GraphSyncError lightning_error(org.ldk.structs.LightningError a) {
81                 long ret = bindings.GraphSyncError_lightning_error(a == null ? 0 : a.ptr);
82                 GC.KeepAlive(a);
83                 if (ret >= 0 && ret <= 4096) { return null; }
84                 org.ldk.structs.GraphSyncError ret_hu_conv = org.ldk.structs.GraphSyncError.constr_from_ptr(ret);
85                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
87                 return ret_hu_conv;
88         }
89
90 }
91 } } }