5b7cd65e8a58b6d5044d0d1d3c9a78262ea6fe4f
[ldk-java] / c_sharp / src / org / ldk / structs / Stfu.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 /**
10  * An stfu (quiescence) message to be sent by or received from the stfu initiator.
11  */
12 public class Stfu : CommonBase {
13         internal Stfu(object _dummy, long ptr) : base(ptr) { }
14         ~Stfu() {
15                 if (ptr != 0) { bindings.Stfu_free(ptr); }
16         }
17
18         /**
19          * The channel ID where quiescence is intended
20          */
21         public ChannelId get_channel_id() {
22                 long ret = bindings.Stfu_get_channel_id(this.ptr);
23                 GC.KeepAlive(this);
24                 if (ret >= 0 && ret <= 4096) { return null; }
25                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
26                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
27                 return ret_hu_conv;
28         }
29
30         /**
31          * The channel ID where quiescence is intended
32          */
33         public void set_channel_id(org.ldk.structs.ChannelId val) {
34                 bindings.Stfu_set_channel_id(this.ptr, val.ptr);
35                 GC.KeepAlive(this);
36                 GC.KeepAlive(val);
37                 if (this != null) { this.ptrs_to.AddLast(val); };
38         }
39
40         /**
41          * Initiator flag, 1 if initiating, 0 if replying to an stfu.
42          */
43         public byte get_initiator() {
44                 byte ret = bindings.Stfu_get_initiator(this.ptr);
45                 GC.KeepAlive(this);
46                 return ret;
47         }
48
49         /**
50          * Initiator flag, 1 if initiating, 0 if replying to an stfu.
51          */
52         public void set_initiator(byte val) {
53                 bindings.Stfu_set_initiator(this.ptr, val);
54                 GC.KeepAlive(this);
55                 GC.KeepAlive(val);
56         }
57
58         /**
59          * Constructs a new Stfu given each field
60          */
61         public static Stfu of(org.ldk.structs.ChannelId channel_id_arg, byte initiator_arg) {
62                 long ret = bindings.Stfu_new(channel_id_arg.ptr, initiator_arg);
63                 GC.KeepAlive(channel_id_arg);
64                 GC.KeepAlive(initiator_arg);
65                 if (ret >= 0 && ret <= 4096) { return null; }
66                 org.ldk.structs.Stfu ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Stfu(null, ret); }
67                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
68                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
69                 return ret_hu_conv;
70         }
71
72         internal long clone_ptr() {
73                 long ret = bindings.Stfu_clone_ptr(this.ptr);
74                 GC.KeepAlive(this);
75                 return ret;
76         }
77
78         /**
79          * Creates a copy of the Stfu
80          */
81         public Stfu clone() {
82                 long ret = bindings.Stfu_clone(this.ptr);
83                 GC.KeepAlive(this);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 org.ldk.structs.Stfu ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Stfu(null, ret); }
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
87                 return ret_hu_conv;
88         }
89
90         /**
91          * Checks if two Stfus contain equal inner contents.
92          * This ignores pointers and is_owned flags and looks at the values in fields.
93          * Two objects with NULL inner values will be considered "equal" here.
94          */
95         public bool eq(org.ldk.structs.Stfu b) {
96                 bool ret = bindings.Stfu_eq(this.ptr, b.ptr);
97                 GC.KeepAlive(this);
98                 GC.KeepAlive(b);
99                 if (this != null) { this.ptrs_to.AddLast(b); };
100                 return ret;
101         }
102
103         public override bool Equals(object o) {
104                 if (!(o is Stfu)) return false;
105                 return this.eq((Stfu)o);
106         }
107         /**
108          * Serialize the Stfu object into a byte array which can be read by Stfu_read
109          */
110         public byte[] write() {
111                 long ret = bindings.Stfu_write(this.ptr);
112                 GC.KeepAlive(this);
113                 if (ret >= 0 && ret <= 4096) { return null; }
114                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
115                 return ret_conv;
116         }
117
118         /**
119          * Read a Stfu from a byte array, created by Stfu_write
120          */
121         public static Result_StfuDecodeErrorZ read(byte[] ser) {
122                 long ret = bindings.Stfu_read(InternalUtils.encodeUint8Array(ser));
123                 GC.KeepAlive(ser);
124                 if (ret >= 0 && ret <= 4096) { return null; }
125                 Result_StfuDecodeErrorZ ret_hu_conv = Result_StfuDecodeErrorZ.constr_from_ptr(ret);
126                 return ret_hu_conv;
127         }
128
129 }
130 } } }