1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
10 public class Result_NonePeerHandleErrorZ extends CommonBase {
11 private Result_NonePeerHandleErrorZ(Object _dummy, long ptr) { super(ptr); }
12 protected void finalize() throws Throwable {
13 if (ptr != 0) { bindings.CResult_NonePeerHandleErrorZ_free(ptr); } super.finalize();
16 static Result_NonePeerHandleErrorZ constr_from_ptr(long ptr) {
17 if (bindings.CResult_NonePeerHandleErrorZ_is_ok(ptr)) {
18 return new Result_NonePeerHandleErrorZ_OK(null, ptr);
20 return new Result_NonePeerHandleErrorZ_Err(null, ptr);
23 public static final class Result_NonePeerHandleErrorZ_OK extends Result_NonePeerHandleErrorZ {
24 private Result_NonePeerHandleErrorZ_OK(Object _dummy, long ptr) {
29 public static final class Result_NonePeerHandleErrorZ_Err extends Result_NonePeerHandleErrorZ {
30 public final PeerHandleError err;
31 private Result_NonePeerHandleErrorZ_Err(Object _dummy, long ptr) {
33 long err = bindings.CResult_NonePeerHandleErrorZ_get_err(ptr);
34 PeerHandleError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new PeerHandleError(null, err); }
35 err_hu_conv.ptrs_to.add(this);
36 this.err = err_hu_conv;
41 * Creates a new CResult_NonePeerHandleErrorZ in the success state.
43 public static Result_NonePeerHandleErrorZ ok() {
44 long ret = bindings.CResult_NonePeerHandleErrorZ_ok();
45 if (ret >= 0 && ret <= 4096) { return null; }
46 Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
51 * Creates a new CResult_NonePeerHandleErrorZ in the error state.
53 public static Result_NonePeerHandleErrorZ err(PeerHandleError e) {
54 long ret = bindings.CResult_NonePeerHandleErrorZ_err(e == null ? 0 : e.ptr & ~1);
55 Reference.reachabilityFence(e);
56 if (ret >= 0 && ret <= 4096) { return null; }
57 Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
62 * Checks if the given object is currently in the success state
64 public boolean is_ok() {
65 boolean ret = bindings.CResult_NonePeerHandleErrorZ_is_ok(this.ptr);
66 Reference.reachabilityFence(this);
71 long ret = bindings.CResult_NonePeerHandleErrorZ_clone_ptr(this.ptr);
72 Reference.reachabilityFence(this);
77 * Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig`
78 * but with all dynamically-allocated buffers duplicated in new buffers.
80 public Result_NonePeerHandleErrorZ clone() {
81 long ret = bindings.CResult_NonePeerHandleErrorZ_clone(this.ptr);
82 Reference.reachabilityFence(this);
83 if (ret >= 0 && ret <= 4096) { return null; }
84 Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);