[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / GossipSync.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  * Either [`P2PGossipSync`] or [`RapidGossipSync`].
10  */
11 public class GossipSync : CommonBase {
12         protected GossipSync(object _dummy, long ptr) : base(ptr) { }
13         ~GossipSync() {
14                 if (ptr != 0) { bindings.GossipSync_free(ptr); }
15         }
16
17         internal static GossipSync constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKGossipSync_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new GossipSync_P2P(ptr);
21                         case 1: return new GossipSync_Rapid(ptr);
22                         case 2: return new GossipSync_None(ptr);
23                         default:
24                                 throw new ArgumentException("Impossible enum variant");
25                 }
26         }
27
28         /** A GossipSync of type P2P */
29         public class GossipSync_P2P : GossipSync {
30                 public P2PGossipSync p2p;
31                 internal GossipSync_P2P(long ptr) : base(null, ptr) {
32                         long p2p = bindings.LDKGossipSync_P2P_get_p2p(ptr);
33                         org.ldk.structs.P2PGossipSync p2p_hu_conv = null; if (p2p < 0 || p2p > 4096) { p2p_hu_conv = new org.ldk.structs.P2PGossipSync(null, p2p); }
34                         if (p2p_hu_conv != null) { p2p_hu_conv.ptrs_to.AddLast(this); };
35                         this.p2p = p2p_hu_conv;
36                 }
37         }
38         /** A GossipSync of type Rapid */
39         public class GossipSync_Rapid : GossipSync {
40                 public RapidGossipSync rapid;
41                 internal GossipSync_Rapid(long ptr) : base(null, ptr) {
42                         long rapid = bindings.LDKGossipSync_Rapid_get_rapid(ptr);
43                         org.ldk.structs.RapidGossipSync rapid_hu_conv = null; if (rapid < 0 || rapid > 4096) { rapid_hu_conv = new org.ldk.structs.RapidGossipSync(null, rapid); }
44                         if (rapid_hu_conv != null) { rapid_hu_conv.ptrs_to.AddLast(this); };
45                         this.rapid = rapid_hu_conv;
46                 }
47         }
48         /** A GossipSync of type None */
49         public class GossipSync_None : GossipSync {
50                 internal GossipSync_None(long ptr) : base(null, ptr) {
51                 }
52         }
53         /**
54          * Utility method to constructs a new P2P-variant GossipSync
55          */
56         public static GossipSync p2_p(org.ldk.structs.P2PGossipSync a) {
57                 long ret = bindings.GossipSync_p2_p(a.ptr);
58                 GC.KeepAlive(a);
59                 if (ret >= 0 && ret <= 4096) { return null; }
60                 org.ldk.structs.GossipSync ret_hu_conv = org.ldk.structs.GossipSync.constr_from_ptr(ret);
61                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
62                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
63                 return ret_hu_conv;
64         }
65
66         /**
67          * Utility method to constructs a new Rapid-variant GossipSync
68          */
69         public static GossipSync rapid(org.ldk.structs.RapidGossipSync a) {
70                 long ret = bindings.GossipSync_rapid(a.ptr);
71                 GC.KeepAlive(a);
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 org.ldk.structs.GossipSync ret_hu_conv = org.ldk.structs.GossipSync.constr_from_ptr(ret);
74                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
75                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
76                 return ret_hu_conv;
77         }
78
79         /**
80          * Utility method to constructs a new None-variant GossipSync
81          */
82         public static GossipSync none() {
83                 long ret = bindings.GossipSync_none();
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 org.ldk.structs.GossipSync ret_hu_conv = org.ldk.structs.GossipSync.constr_from_ptr(ret);
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
87                 return ret_hu_conv;
88         }
89
90 }
91 } } }