6 namespace org { namespace ldk { namespace structs {
9 * Defines a type identifier for sending messages over the wire.
11 * Messages implementing this trait specify a type and must be [`Writeable`].
13 public class Type : CommonBase {
14 internal readonly bindings.LDKType bindings_instance;
15 internal Type(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
16 private Type(bindings.LDKType arg) : base(bindings.LDKType_new(arg)) {
17 this.ptrs_to.AddLast(arg);
18 this.bindings_instance = arg;
21 if (ptr != 0) { bindings.Type_free(ptr); }
24 public interface TypeInterface {
26 * Returns the type identifying the message payload.
30 * Return a human-readable "debug" string describing this object
34 * Serialize the object into a byte array
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 string debug_str() {
49 string ret = arg.debug_str();
53 public byte[] write() {
54 byte[] ret = arg.write();
59 public static Type new_impl(TypeInterface arg) {
60 LDKTypeHolder impl_holder = new LDKTypeHolder();
61 impl_holder.held = new Type(new LDKTypeImpl(arg, impl_holder));
62 return impl_holder.held;
65 * Returns the type identifying the message payload.
67 public short type_id() {
68 short ret = bindings.Type_type_id(this.ptr);
74 * Return a human-readable "debug" string describing this object
76 public string debug_str() {
77 string ret = bindings.Type_debug_str(this.ptr);
83 * Serialize the object into a byte array
85 public byte[] write() {
86 byte[] ret = bindings.Type_write(this.ptr);
91 internal long clone_ptr() {
92 long ret = bindings.Type_clone_ptr(this.ptr);
98 * Creates a copy of a Type
100 public Type clone() {
101 long ret = bindings.Type_clone(this.ptr);
103 if (ret >= 0 && ret <= 4096) { return null; }
104 Type ret_hu_conv = new Type(null, ret);
105 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };