[Java] Update auto-generated bindings to 0.0.105.0
[ldk-java] / src / main / java / org / ldk / structs / Scorer.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * [`Score`] implementation that provides reasonable default behavior.
13  * 
14  * Used to apply a fixed penalty to each channel, thus avoiding long paths when shorter paths with
15  * slightly higher fees are available. Will further penalize channels that fail to relay payments.
16  * 
17  * See [module-level documentation] for usage and [`ScoringParameters`] for customization.
18  * 
19  * # Note
20  * 
21  * Mixing the `no-std` feature between serialization and deserialization results in undefined
22  * behavior.
23  * 
24  * [module-level documentation]: crate::routing::scoring
25  */
26 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
27 public class Scorer extends CommonBase {
28         Scorer(Object _dummy, long ptr) { super(ptr); }
29         @Override @SuppressWarnings("deprecation")
30         protected void finalize() throws Throwable {
31                 super.finalize();
32                 if (ptr != 0) { bindings.Scorer_free(ptr); }
33         }
34
35         /**
36          * Creates a new scorer using the given scoring parameters.
37          */
38         public static Scorer of(ScoringParameters params) {
39                 long ret = bindings.Scorer_new(params == null ? 0 : params.ptr & ~1);
40                 Reference.reachabilityFence(params);
41                 if (ret >= 0 && ret <= 4096) { return null; }
42                 Scorer ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Scorer(null, ret); }
43                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
44                 return ret_hu_conv;
45         }
46
47         /**
48          * Creates a "default" Scorer. See struct and individual field documentaiton for details on which values are used.
49          */
50         public static Scorer with_default() {
51                 long ret = bindings.Scorer_default();
52                 if (ret >= 0 && ret <= 4096) { return null; }
53                 Scorer ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Scorer(null, ret); }
54                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
55                 return ret_hu_conv;
56         }
57
58         /**
59          * Constructs a new Score which calls the relevant methods on this_arg.
60          * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is
61          */
62         public Score as_Score() {
63                 long ret = bindings.Scorer_as_Score(this.ptr);
64                 Reference.reachabilityFence(this);
65                 if (ret >= 0 && ret <= 4096) { return null; }
66                 Score ret_hu_conv = new Score(null, ret);
67                 ret_hu_conv.ptrs_to.add(this);
68                 return ret_hu_conv;
69         }
70
71         /**
72          * Serialize the Scorer object into a byte array which can be read by Scorer_read
73          */
74         public byte[] write() {
75                 byte[] ret = bindings.Scorer_write(this.ptr);
76                 Reference.reachabilityFence(this);
77                 return ret;
78         }
79
80         /**
81          * Read a Scorer from a byte array, created by Scorer_write
82          */
83         public static Result_ScorerDecodeErrorZ read(byte[] ser) {
84                 long ret = bindings.Scorer_read(ser);
85                 Reference.reachabilityFence(ser);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 Result_ScorerDecodeErrorZ ret_hu_conv = Result_ScorerDecodeErrorZ.constr_from_ptr(ret);
88                 return ret_hu_conv;
89         }
90
91 }