46172256c02505797f7c8a2b224ac47f29b0b4b0
[ldk-java] / src / main / java / org / ldk / structs / Result_TrustedCommitmentTransactionNoneZ.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
8 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
9 public class Result_TrustedCommitmentTransactionNoneZ extends CommonBase {
10         private Result_TrustedCommitmentTransactionNoneZ(Object _dummy, long ptr) { super(ptr); }
11         protected void finalize() throws Throwable {
12                 if (ptr != 0) { bindings.CResult_TrustedCommitmentTransactionNoneZ_free(ptr); } super.finalize();
13         }
14
15         static Result_TrustedCommitmentTransactionNoneZ constr_from_ptr(long ptr) {
16                 if (bindings.LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(ptr)) {
17                         return new Result_TrustedCommitmentTransactionNoneZ_OK(null, ptr);
18                 } else {
19                         return new Result_TrustedCommitmentTransactionNoneZ_Err(null, ptr);
20                 }
21         }
22         public static final class Result_TrustedCommitmentTransactionNoneZ_OK extends Result_TrustedCommitmentTransactionNoneZ {
23                 public final TrustedCommitmentTransaction res;
24                 private Result_TrustedCommitmentTransactionNoneZ_OK(Object _dummy, long ptr) {
25                         super(_dummy, ptr);
26                         long res = bindings.LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(ptr);
27                         TrustedCommitmentTransaction res_hu_conv = new TrustedCommitmentTransaction(null, res);
28                         res_hu_conv.ptrs_to.add(this);
29                         this.res = res_hu_conv;
30                 }
31                 public Result_TrustedCommitmentTransactionNoneZ_OK(TrustedCommitmentTransaction res) {
32                         this(null, bindings.CResult_TrustedCommitmentTransactionNoneZ_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.
41                         res.ptr = 0;
42                 }
43         }
44
45         public static final class Result_TrustedCommitmentTransactionNoneZ_Err extends Result_TrustedCommitmentTransactionNoneZ {
46                 private Result_TrustedCommitmentTransactionNoneZ_Err(Object _dummy, long ptr) {
47                         super(_dummy, ptr);
48                 }
49                 public Result_TrustedCommitmentTransactionNoneZ_Err() {
50                         this(null, bindings.CResult_TrustedCommitmentTransactionNoneZ_err());
51                 }
52         }
53 }