1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
8 public class Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ extends CommonBase {
9 private Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
10 protected void finalize() throws Throwable {
11 if (ptr != 0) { bindings.CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(ptr); } super.finalize();
14 static Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ constr_from_ptr(long ptr) {
15 if (bindings.LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(ptr)) {
16 return new Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK(null, ptr);
18 return new Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_Err(null, ptr);
21 public static final class Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK extends Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
22 public final TwoTuple<byte[], ChannelManager> res;
23 private Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK(Object _dummy, long ptr) {
25 long res = bindings.LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(ptr);
26 byte[] res_a = bindings.LDKC2Tuple_BlockHashChannelManagerZ_get_a(res);
27 long res_b = bindings.LDKC2Tuple_BlockHashChannelManagerZ_get_b(res);
28 ChannelManager res_b_hu_conv = new ChannelManager(null, res_b);
29 res_b_hu_conv.ptrs_to.add(this);;
30 TwoTuple<byte[], ChannelManager> res_conv = new TwoTuple<byte[], ChannelManager>(res_a, res_b_hu_conv, () -> {
31 bindings.C2Tuple_BlockHashChannelManagerZ_free(res);
33 res_b_hu_conv.ptrs_to.add(res_conv);
36 public Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK(TwoTuple<byte[], ChannelManager> res) {
37 this(null, bindings.CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(bindings.C2Tuple_BlockHashChannelManagerZ_new(res.a, res.b == null ? 0 : res.b.ptr & ~1)));
38 this.ptrs_to.add(res.b);
39 // Due to rust's strict-ownership memory model, in some cases we need to "move"
40 // an object to pass exclusive ownership to the function being called.
41 // In most cases, we avoid this being visible in GC'd languages by cloning the object
42 // at the FFI layer, creating a new object which Rust can claim ownership of
43 // However, in some cases (eg here), there is no way to clone an object, and thus
44 // we actually have to pass full ownership to Rust.
45 // Thus, after this call, res.b is reset to null and is now a dummy object.
50 public static final class Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_Err extends Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
51 public final DecodeError err;
52 private Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_Err(Object _dummy, long ptr) {
54 long err = bindings.LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(ptr);
55 DecodeError err_hu_conv = new DecodeError(null, err);
56 err_hu_conv.ptrs_to.add(this);
57 this.err = err_hu_conv;
59 public Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_Err(DecodeError err) {
60 this(null, bindings.CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(err == null ? 0 : err.ptr & ~1));
61 this.ptrs_to.add(err);