1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
8 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
9 public class Result_NetworkGraphDecodeErrorZ extends CommonBase {
10 private Result_NetworkGraphDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
11 protected void finalize() throws Throwable {
12 if (ptr != 0) { bindings.CResult_NetworkGraphDecodeErrorZ_free(ptr); } super.finalize();
15 static Result_NetworkGraphDecodeErrorZ constr_from_ptr(long ptr) {
16 if (bindings.LDKCResult_NetworkGraphDecodeErrorZ_result_ok(ptr)) {
17 return new Result_NetworkGraphDecodeErrorZ_OK(null, ptr);
19 return new Result_NetworkGraphDecodeErrorZ_Err(null, ptr);
22 public static final class Result_NetworkGraphDecodeErrorZ_OK extends Result_NetworkGraphDecodeErrorZ {
23 public final NetworkGraph res;
24 private Result_NetworkGraphDecodeErrorZ_OK(Object _dummy, long ptr) {
26 long res = bindings.LDKCResult_NetworkGraphDecodeErrorZ_get_ok(ptr);
27 NetworkGraph res_hu_conv = new NetworkGraph(null, res);
28 res_hu_conv.ptrs_to.add(this);
29 this.res = res_hu_conv;
31 public Result_NetworkGraphDecodeErrorZ_OK(NetworkGraph res) {
32 this(null, bindings.CResult_NetworkGraphDecodeErrorZ_ok(res == null ? 0 : res.ptr & ~1));
33 this.ptrs_to.add(res);
34 // Due to rust's strict-ownership memory model, in some cases we need to "move"
35 // an object to pass exclusive ownership to the function being called.
36 // In most cases, we avoid this being visible in GC'd languages by cloning the object
37 // at the FFI layer, creating a new object which Rust can claim ownership of
38 // However, in some cases (eg here), there is no way to clone an object, and thus
39 // we actually have to pass full ownership to Rust.
40 // Thus, after this call, res is reset to null and is now a dummy object.
45 public static final class Result_NetworkGraphDecodeErrorZ_Err extends Result_NetworkGraphDecodeErrorZ {
46 public final DecodeError err;
47 private Result_NetworkGraphDecodeErrorZ_Err(Object _dummy, long ptr) {
49 long err = bindings.LDKCResult_NetworkGraphDecodeErrorZ_get_err(ptr);
50 DecodeError err_hu_conv = new DecodeError(null, err);
51 err_hu_conv.ptrs_to.add(this);
52 this.err = err_hu_conv;
54 public Result_NetworkGraphDecodeErrorZ_Err(DecodeError err) {
55 this(null, bindings.CResult_NetworkGraphDecodeErrorZ_err(err == null ? 0 : err.ptr & ~1));
56 this.ptrs_to.add(err);