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_NoneAPIErrorZ extends CommonBase {
11 private Result_NoneAPIErrorZ(Object _dummy, long ptr) { super(ptr); }
12 protected void finalize() throws Throwable {
13 if (ptr != 0) { bindings.CResult_NoneAPIErrorZ_free(ptr); } super.finalize();
16 static Result_NoneAPIErrorZ constr_from_ptr(long ptr) {
17 if (bindings.CResult_NoneAPIErrorZ_is_ok(ptr)) {
18 return new Result_NoneAPIErrorZ_OK(null, ptr);
20 return new Result_NoneAPIErrorZ_Err(null, ptr);
23 public static final class Result_NoneAPIErrorZ_OK extends Result_NoneAPIErrorZ {
24 private Result_NoneAPIErrorZ_OK(Object _dummy, long ptr) {
29 public static final class Result_NoneAPIErrorZ_Err extends Result_NoneAPIErrorZ {
30 public final APIError err;
31 private Result_NoneAPIErrorZ_Err(Object _dummy, long ptr) {
33 long err = bindings.LDKCResult_NoneAPIErrorZ_get_err(ptr);
34 APIError err_hu_conv = APIError.constr_from_ptr(err);
35 err_hu_conv.ptrs_to.add(this);
36 this.err = err_hu_conv;
41 * Creates a new CResult_NoneAPIErrorZ in the success state.
43 public static Result_NoneAPIErrorZ ok() {
44 long ret = bindings.CResult_NoneAPIErrorZ_ok();
45 if (ret >= 0 && ret <= 4096) { return null; }
46 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
51 * Creates a new CResult_NoneAPIErrorZ in the error state.
53 public static Result_NoneAPIErrorZ err(APIError e) {
54 long ret = bindings.CResult_NoneAPIErrorZ_err(e.ptr);
55 Reference.reachabilityFence(e);
56 if (ret >= 0 && ret <= 4096) { return null; }
57 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.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_NoneAPIErrorZ_is_ok(this.ptr);
66 Reference.reachabilityFence(this);
71 long ret = bindings.CResult_NoneAPIErrorZ_clone_ptr(this.ptr);
72 Reference.reachabilityFence(this);
77 * Creates a new CResult_NoneAPIErrorZ which has the same data as `orig`
78 * but with all dynamically-allocated buffers duplicated in new buffers.
80 public Result_NoneAPIErrorZ clone() {
81 long ret = bindings.CResult_NoneAPIErrorZ_clone(this.ptr);
82 Reference.reachabilityFence(this);
83 if (ret >= 0 && ret <= 4096) { return null; }
84 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);