]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.ts
Merge pull request #14 from TheBlueMatt/2021-03-fix-enums
[ldk-java] / ts / structs / Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.ts
1
2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
4
5 public class Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ extends CommonBase {
6         private Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
7         protected void finalize() throws Throwable {
8                 if (ptr != 0) { bindings.CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(ptr); } super.finalize();
9         }
10
11         static Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ constr_from_ptr(long ptr) {
12                 if (bindings.LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(ptr)) {
13                         return new Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK(null, ptr);
14                 } else {
15                         return new Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_Err(null, ptr);
16                 }
17         }
18         public static final class Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK extends Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
19                 public final TwoTuple<Uint8Array, ChannelManager> res;
20                 private Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK(Object _dummy, long ptr) {
21                         super(_dummy, ptr);
22                         number res = bindings.LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(ptr);
23                         Uint8Array res_a = bindings.LDKC2Tuple_BlockHashChannelManagerZ_get_a(res);
24                         number res_b = bindings.LDKC2Tuple_BlockHashChannelManagerZ_get_b(res);
25                         const res_b_hu_conv: ChannelManager = new ChannelManager(null, res_b);
26                         res_b_hu_conv.ptrs_to.add(this);;
27                         TwoTuple<Uint8Array, ChannelManager> res_conv = new TwoTuple<Uint8Array, ChannelManager>(res_a, res_b_hu_conv, () -> {
28                                 bindings.C2Tuple_BlockHashChannelManagerZ_free(res);
29                         });
30                         res_b_hu_conv.ptrs_to.add(res_conv);
31                         this.res = res_conv;
32                 }
33         }
34
35         public static final class Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_Err extends Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
36                 public final DecodeError err;
37                 private Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_Err(Object _dummy, long ptr) {
38                         super(_dummy, ptr);
39                         number err = bindings.LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(ptr);
40                         const err_hu_conv: DecodeError = new DecodeError(null, err);
41                         err_hu_conv.ptrs_to.add(this);
42                         this.err = err_hu_conv;
43                 }
44         }
45
46         public static Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ constructor__ok(TwoTuple<Uint8Array, ChannelManager> o) {
47                 number ret = bindings.CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(bindings.C2Tuple_BlockHashChannelManagerZ_new(o.a, o.b == null ? 0 : o.b.ptr & ~1));
48                 Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
49                 ret_hu_conv.ptrs_to.add(o.b);
50                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
51                 // an object to pass exclusive ownership to the function being called.
52                 // In most cases, we avoid ret_hu_conv being visible in GC'd languages by cloning the object
53                 // at the FFI layer, creating a new object which Rust can claim ownership of
54                 // However, in some cases (eg here), there is no way to clone an object, and thus
55                 // we actually have to pass full ownership to Rust.
56                 // Thus, after ret_hu_conv call, o.b is reset to null and is now a dummy object.
57                 o.b.ptr = 0;
58                 return ret_hu_conv;
59         }
60
61         public static Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ constructor__err(DecodeError e) {
62                 number ret = bindings.CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
63                 Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
64                 ret_hu_conv.ptrs_to.add(e);
65                 return ret_hu_conv;
66         }
67
68 }