[C#] Check in initial auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Destination.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  * The destination of an onion message.
10  */
11 public class Destination : CommonBase {
12         protected Destination(object _dummy, long ptr) : base(ptr) { }
13         ~Destination() {
14                 if (ptr != 0) { bindings.Destination_free(ptr); }
15         }
16
17         internal static Destination constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKDestination_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new Destination_Node(ptr);
21                         case 1: return new Destination_BlindedPath(ptr);
22                         default:
23                                 throw new ArgumentException("Impossible enum variant");
24                 }
25         }
26
27         /** A Destination of type Node */
28         public class Destination_Node : Destination {
29                 public byte[] node;
30                 internal Destination_Node(long ptr) : base(null, ptr) {
31                         this.node = bindings.LDKDestination_Node_get_node(ptr);
32                 }
33         }
34         /** A Destination of type BlindedPath */
35         public class Destination_BlindedPath : Destination {
36                 public BlindedPath blinded_path;
37                 internal Destination_BlindedPath(long ptr) : base(null, ptr) {
38                         long blinded_path = bindings.LDKDestination_BlindedPath_get_blinded_path(ptr);
39                         org.ldk.structs.BlindedPath blinded_path_hu_conv = null; if (blinded_path < 0 || blinded_path > 4096) { blinded_path_hu_conv = new org.ldk.structs.BlindedPath(null, blinded_path); }
40                         if (blinded_path_hu_conv != null) { blinded_path_hu_conv.ptrs_to.AddLast(this); };
41                         this.blinded_path = blinded_path_hu_conv;
42                 }
43         }
44         internal long clone_ptr() {
45                 long ret = bindings.Destination_clone_ptr(this.ptr);
46                 GC.KeepAlive(this);
47                 return ret;
48         }
49
50         /**
51          * Creates a copy of the Destination
52          */
53         public Destination clone() {
54                 long ret = bindings.Destination_clone(this.ptr);
55                 GC.KeepAlive(this);
56                 if (ret >= 0 && ret <= 4096) { return null; }
57                 org.ldk.structs.Destination ret_hu_conv = org.ldk.structs.Destination.constr_from_ptr(ret);
58                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
59                 return ret_hu_conv;
60         }
61
62         /**
63          * Utility method to constructs a new Node-variant Destination
64          */
65         public static Destination node(byte[] a) {
66                 long ret = bindings.Destination_node(InternalUtils.check_arr_len(a, 33));
67                 GC.KeepAlive(a);
68                 if (ret >= 0 && ret <= 4096) { return null; }
69                 org.ldk.structs.Destination ret_hu_conv = org.ldk.structs.Destination.constr_from_ptr(ret);
70                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
71                 return ret_hu_conv;
72         }
73
74         /**
75          * Utility method to constructs a new BlindedPath-variant Destination
76          */
77         public static Destination blinded_path(org.ldk.structs.BlindedPath a) {
78                 long ret = bindings.Destination_blinded_path(a == null ? 0 : a.ptr);
79                 GC.KeepAlive(a);
80                 if (ret >= 0 && ret <= 4096) { return null; }
81                 org.ldk.structs.Destination ret_hu_conv = org.ldk.structs.Destination.constr_from_ptr(ret);
82                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
83                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
84                 return ret_hu_conv;
85         }
86
87 }
88 } } }