[Java] Update auto-generated Java files
[ldk-java] / src / main / java / org / ldk / structs / SendError.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Errors that may occur when [sending an onion message].
13  * 
14  * [sending an onion message]: OnionMessenger::send_onion_message
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class SendError extends CommonBase {
18         private SendError(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.SendError_free(ptr); }
23         }
24         static SendError constr_from_ptr(long ptr) {
25                 bindings.LDKSendError raw_val = bindings.LDKSendError_ref_from_ptr(ptr);
26                 if (raw_val.getClass() == bindings.LDKSendError.Secp256k1.class) {
27                         return new Secp256k1(ptr, (bindings.LDKSendError.Secp256k1)raw_val);
28                 }
29                 if (raw_val.getClass() == bindings.LDKSendError.TooBigPacket.class) {
30                         return new TooBigPacket(ptr, (bindings.LDKSendError.TooBigPacket)raw_val);
31                 }
32                 if (raw_val.getClass() == bindings.LDKSendError.TooFewBlindedHops.class) {
33                         return new TooFewBlindedHops(ptr, (bindings.LDKSendError.TooFewBlindedHops)raw_val);
34                 }
35                 if (raw_val.getClass() == bindings.LDKSendError.InvalidFirstHop.class) {
36                         return new InvalidFirstHop(ptr, (bindings.LDKSendError.InvalidFirstHop)raw_val);
37                 }
38                 if (raw_val.getClass() == bindings.LDKSendError.BufferFull.class) {
39                         return new BufferFull(ptr, (bindings.LDKSendError.BufferFull)raw_val);
40                 }
41                 assert false; return null; // Unreachable without extending the (internal) bindings interface
42         }
43
44         /**
45          * Errored computing onion message packet keys.
46          */
47         public final static class Secp256k1 extends SendError {
48                 public final org.ldk.enums.Secp256k1Error secp256k1;
49                 private Secp256k1(long ptr, bindings.LDKSendError.Secp256k1 obj) {
50                         super(null, ptr);
51                         this.secp256k1 = obj.secp256k1;
52                 }
53         }
54         /**
55          * Because implementations such as Eclair will drop onion messages where the message packet
56          * exceeds 32834 bytes, we refuse to send messages where the packet exceeds this size.
57          */
58         public final static class TooBigPacket extends SendError {
59                 private TooBigPacket(long ptr, bindings.LDKSendError.TooBigPacket obj) {
60                         super(null, ptr);
61                 }
62         }
63         /**
64          * The provided [`Destination`] was an invalid [`BlindedRoute`], due to having fewer than two
65          * blinded hops.
66          */
67         public final static class TooFewBlindedHops extends SendError {
68                 private TooFewBlindedHops(long ptr, bindings.LDKSendError.TooFewBlindedHops obj) {
69                         super(null, ptr);
70                 }
71         }
72         /**
73          * Our next-hop peer was offline or does not support onion message forwarding.
74          */
75         public final static class InvalidFirstHop extends SendError {
76                 private InvalidFirstHop(long ptr, bindings.LDKSendError.InvalidFirstHop obj) {
77                         super(null, ptr);
78                 }
79         }
80         /**
81          * Our next-hop peer's buffer was full or our total outbound buffer was full.
82          */
83         public final static class BufferFull extends SendError {
84                 private BufferFull(long ptr, bindings.LDKSendError.BufferFull obj) {
85                         super(null, ptr);
86                 }
87         }
88         long clone_ptr() {
89                 long ret = bindings.SendError_clone_ptr(this.ptr);
90                 Reference.reachabilityFence(this);
91                 return ret;
92         }
93
94         /**
95          * Creates a copy of the SendError
96          */
97         public SendError clone() {
98                 long ret = bindings.SendError_clone(this.ptr);
99                 Reference.reachabilityFence(this);
100                 if (ret >= 0 && ret <= 4096) { return null; }
101                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
102                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
103                 return ret_hu_conv;
104         }
105
106         /**
107          * Utility method to constructs a new Secp256k1-variant SendError
108          */
109         public static SendError secp256k1(org.ldk.enums.Secp256k1Error a) {
110                 long ret = bindings.SendError_secp256k1(a);
111                 Reference.reachabilityFence(a);
112                 if (ret >= 0 && ret <= 4096) { return null; }
113                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
114                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
115                 return ret_hu_conv;
116         }
117
118         /**
119          * Utility method to constructs a new TooBigPacket-variant SendError
120          */
121         public static SendError too_big_packet() {
122                 long ret = bindings.SendError_too_big_packet();
123                 if (ret >= 0 && ret <= 4096) { return null; }
124                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
125                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
126                 return ret_hu_conv;
127         }
128
129         /**
130          * Utility method to constructs a new TooFewBlindedHops-variant SendError
131          */
132         public static SendError too_few_blinded_hops() {
133                 long ret = bindings.SendError_too_few_blinded_hops();
134                 if (ret >= 0 && ret <= 4096) { return null; }
135                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
136                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
137                 return ret_hu_conv;
138         }
139
140         /**
141          * Utility method to constructs a new InvalidFirstHop-variant SendError
142          */
143         public static SendError invalid_first_hop() {
144                 long ret = bindings.SendError_invalid_first_hop();
145                 if (ret >= 0 && ret <= 4096) { return null; }
146                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
147                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
148                 return ret_hu_conv;
149         }
150
151         /**
152          * Utility method to constructs a new BufferFull-variant SendError
153          */
154         public static SendError buffer_full() {
155                 long ret = bindings.SendError_buffer_full();
156                 if (ret >= 0 && ret <= 4096) { return null; }
157                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
158                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
159                 return ret_hu_conv;
160         }
161
162 }