7 namespace org { namespace ldk { namespace structs {
11 /** An implementation of Type */
12 public interface TypeInterface {
13 /**Returns the type identifying the message payload.
16 /**Return a human-readable "debug" string describing this object
19 /**Serialize the object into a byte array
25 * Defines a type identifier for sending messages over the wire.
27 * Messages implementing this trait specify a type and must be [`Writeable`].
29 public class Type : CommonBase {
30 internal bindings.LDKType bindings_instance;
31 internal long instance_idx;
33 internal Type(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
35 if (ptr != 0) { bindings.Type_free(ptr); }
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();
48 public long debug_str() {
49 string ret = arg.debug_str();
51 long result = InternalUtils.encodeString(ret);
55 byte[] ret = arg.write();
57 long result = InternalUtils.encodeUint8Array(ret);
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);
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;
75 * Returns the type identifying the message payload.
77 public short type_id() {
78 short ret = bindings.Type_type_id(this.ptr);
84 * Return a human-readable "debug" string describing this object
86 public string debug_str() {
87 long ret = bindings.Type_debug_str(this.ptr);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 string ret_conv = InternalUtils.decodeString(ret);
95 * Serialize the object into a byte array
97 public byte[] write() {
98 long ret = bindings.Type_write(this.ptr);
100 if (ret >= 0 && ret <= 4096) { return null; }
101 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
105 internal long clone_ptr() {
106 long ret = bindings.Type_clone_ptr(this.ptr);
112 * Creates a copy of a Type
114 public Type clone() {
115 long ret = bindings.Type_clone(this.ptr);
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); };