2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
5 public class Result_NetworkGraphDecodeErrorZ extends CommonBase {
6 private Result_NetworkGraphDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
7 protected void finalize() throws Throwable {
8 if (ptr != 0) { bindings.CResult_NetworkGraphDecodeErrorZ_free(ptr); } super.finalize();
11 static Result_NetworkGraphDecodeErrorZ constr_from_ptr(long ptr) {
12 if (bindings.LDKCResult_NetworkGraphDecodeErrorZ_result_ok(ptr)) {
13 return new Result_NetworkGraphDecodeErrorZ_OK(null, ptr);
15 return new Result_NetworkGraphDecodeErrorZ_Err(null, ptr);
18 public static final class Result_NetworkGraphDecodeErrorZ_OK extends Result_NetworkGraphDecodeErrorZ {
19 public final NetworkGraph res;
20 private Result_NetworkGraphDecodeErrorZ_OK(Object _dummy, long ptr) {
22 number res = bindings.LDKCResult_NetworkGraphDecodeErrorZ_get_ok(ptr);
23 const res_hu_conv: NetworkGraph = new NetworkGraph(null, res);
24 res_hu_conv.ptrs_to.add(this);
25 this.res = res_hu_conv;
27 public Result_NetworkGraphDecodeErrorZ_OK(NetworkGraph res) {
28 this(null, bindings.CResult_NetworkGraphDecodeErrorZ_ok(res == null ? 0 : res.ptr & ~1));
29 this.ptrs_to.add(res);
30 // Due to rust's strict-ownership memory model, in some cases we need to "move"
31 // an object to pass exclusive ownership to the function being called.
32 // In most cases, we avoid this being visible in GC'd languages by cloning the object
33 // at the FFI layer, creating a new object which Rust can claim ownership of
34 // However, in some cases (eg here), there is no way to clone an object, and thus
35 // we actually have to pass full ownership to Rust.
36 // Thus, after this call, res is reset to null and is now a dummy object.
41 public static final class Result_NetworkGraphDecodeErrorZ_Err extends Result_NetworkGraphDecodeErrorZ {
42 public final DecodeError err;
43 private Result_NetworkGraphDecodeErrorZ_Err(Object _dummy, long ptr) {
45 number err = bindings.LDKCResult_NetworkGraphDecodeErrorZ_get_err(ptr);
46 const err_hu_conv: DecodeError = new DecodeError(null, err);
47 err_hu_conv.ptrs_to.add(this);
48 this.err = err_hu_conv;
50 public Result_NetworkGraphDecodeErrorZ_Err(DecodeError err) {
51 this(null, bindings.CResult_NetworkGraphDecodeErrorZ_err(err == null ? 0 : err.ptr & ~1));
52 this.ptrs_to.add(err);