[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Type.cs
1
2 using org.ldk.impl;
3 using org.ldk.enums;
4 using org.ldk.util;
5 using System;
6
7 namespace org { namespace ldk { namespace structs {
8
9
10
11 /** An implementation of Type */
12 public interface TypeInterface {
13         /**Returns the type identifying the message payload.
14          */
15         short type_id();
16         /**Return a human-readable "debug" string describing this object
17          */
18         string debug_str();
19         /**Serialize the object into a byte array
20          */
21         byte[] write();
22 }
23
24 /**
25  * Defines a type identifier for sending messages over the wire.
26  * 
27  * Messages implementing this trait specify a type and must be [`Writeable`].
28  */
29 public class Type : CommonBase {
30         internal bindings.LDKType bindings_instance;
31         internal long instance_idx;
32
33         internal Type(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
34         ~Type() {
35                 if (ptr != 0) { bindings.Type_free(ptr); }
36         }
37
38         private class LDKTypeHolder { internal Type held; }
39         private class LDKTypeImpl : bindings.LDKType {
40                 internal LDKTypeImpl(TypeInterface arg, LDKTypeHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
41                 private TypeInterface arg;
42                 private LDKTypeHolder impl_holder;
43                 public short type_id() {
44                         short ret = arg.type_id();
45                                 GC.KeepAlive(arg);
46                         return ret;
47                 }
48                 public long debug_str() {
49                         string ret = arg.debug_str();
50                                 GC.KeepAlive(arg);
51                         long result = InternalUtils.encodeString(ret);
52                         return result;
53                 }
54                 public long write() {
55                         byte[] ret = arg.write();
56                                 GC.KeepAlive(arg);
57                         long result = InternalUtils.encodeUint8Array(ret);
58                         return result;
59                 }
60         }
61
62         /** Creates a new instance of Type from a given implementation */
63         public static Type new_impl(TypeInterface arg) {
64                 LDKTypeHolder impl_holder = new LDKTypeHolder();
65                 LDKTypeImpl impl = new LDKTypeImpl(arg, impl_holder);
66                 long[] ptr_idx = bindings.LDKType_new(impl);
67
68                 impl_holder.held = new Type(null, ptr_idx[0]);
69                 impl_holder.held.instance_idx = ptr_idx[1];
70                 impl_holder.held.bindings_instance = impl;
71                 return impl_holder.held;
72         }
73
74         /**
75          * Returns the type identifying the message payload.
76          */
77         public short type_id() {
78                 short ret = bindings.Type_type_id(this.ptr);
79                 GC.KeepAlive(this);
80                 return ret;
81         }
82
83         /**
84          * Return a human-readable "debug" string describing this object
85          */
86         public string debug_str() {
87                 long ret = bindings.Type_debug_str(this.ptr);
88                 GC.KeepAlive(this);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 string ret_conv = InternalUtils.decodeString(ret);
91                 return ret_conv;
92         }
93
94         /**
95          * Serialize the object into a byte array
96          */
97         public byte[] write() {
98                 long ret = bindings.Type_write(this.ptr);
99                 GC.KeepAlive(this);
100                 if (ret >= 0 && ret <= 4096) { return null; }
101                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
102                 return ret_conv;
103         }
104
105         internal long clone_ptr() {
106                 long ret = bindings.Type_clone_ptr(this.ptr);
107                 GC.KeepAlive(this);
108                 return ret;
109         }
110
111         /**
112          * Creates a copy of a Type
113          */
114         public Type clone() {
115                 long ret = bindings.Type_clone(this.ptr);
116                 GC.KeepAlive(this);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 Type ret_hu_conv = new Type(null, ret);
119                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
120                 return ret_hu_conv;
121         }
122
123 }
124 } } }