1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
9 public class Result_ScorerDecodeErrorZ extends CommonBase {
10 private Result_ScorerDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
11 protected void finalize() throws Throwable {
12 if (ptr != 0) { bindings.CResult_ScorerDecodeErrorZ_free(ptr); } super.finalize();
15 static Result_ScorerDecodeErrorZ constr_from_ptr(long ptr) {
16 if (bindings.CResult_ScorerDecodeErrorZ_is_ok(ptr)) {
17 return new Result_ScorerDecodeErrorZ_OK(null, ptr);
19 return new Result_ScorerDecodeErrorZ_Err(null, ptr);
22 public static final class Result_ScorerDecodeErrorZ_OK extends Result_ScorerDecodeErrorZ {
23 public final Scorer res;
24 private Result_ScorerDecodeErrorZ_OK(Object _dummy, long ptr) {
26 long res = bindings.LDKCResult_ScorerDecodeErrorZ_get_ok(ptr);
27 Scorer res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new Scorer(null, res); }
28 res_hu_conv.ptrs_to.add(this);
29 this.res = res_hu_conv;
33 public static final class Result_ScorerDecodeErrorZ_Err extends Result_ScorerDecodeErrorZ {
34 public final DecodeError err;
35 private Result_ScorerDecodeErrorZ_Err(Object _dummy, long ptr) {
37 long err = bindings.LDKCResult_ScorerDecodeErrorZ_get_err(ptr);
38 DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
39 err_hu_conv.ptrs_to.add(this);
40 this.err = err_hu_conv;
45 * Creates a new CResult_ScorerDecodeErrorZ in the success state.
47 public static Result_ScorerDecodeErrorZ ok(ScoringParameters o_params) {
48 long ret = bindings.CResult_ScorerDecodeErrorZ_ok(bindings.Scorer_new(o_params == null ? 0 : o_params.ptr & ~1));
49 if (ret >= 0 && ret <= 4096) { return null; }
50 Result_ScorerDecodeErrorZ ret_hu_conv = Result_ScorerDecodeErrorZ.constr_from_ptr(ret);
51 ret_hu_conv.ptrs_to.add(o_params);
52 // Due to rust's strict-ownership memory model, in some cases we need to "move"
53 // an object to pass exclusive ownership to the function being called.
54 // In most cases, we avoid ret_hu_conv being visible in GC'd languages by cloning the object
55 // at the FFI layer, creating a new object which Rust can claim ownership of
56 // However, in some cases (eg here), there is no way to clone an object, and thus
57 // we actually have to pass full ownership to Rust.
58 // Thus, after ret_hu_conv call, o_params is reset to null and is now a dummy object.
64 * Creates a new CResult_ScorerDecodeErrorZ in the error state.
66 public static Result_ScorerDecodeErrorZ err(DecodeError e) {
67 long ret = bindings.CResult_ScorerDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
68 if (ret >= 0 && ret <= 4096) { return null; }
69 Result_ScorerDecodeErrorZ ret_hu_conv = Result_ScorerDecodeErrorZ.constr_from_ptr(ret);
74 * Checks if the given object is currently in the success state
76 public boolean is_ok() {
77 boolean ret = bindings.CResult_ScorerDecodeErrorZ_is_ok(this.ptr);