CSharp: fix LDKStr array decoding
[ldk-java] / c_sharp / src / org / ldk / structs / Result_TrustedClosingTransactionNoneZ.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8 public class Result_TrustedClosingTransactionNoneZ : CommonBase {
9         Result_TrustedClosingTransactionNoneZ(object _dummy, long ptr) : base(ptr) { }
10         ~Result_TrustedClosingTransactionNoneZ() {
11                 if (ptr != 0) { bindings.CResult_TrustedClosingTransactionNoneZ_free(ptr); }
12         }
13
14         internal static Result_TrustedClosingTransactionNoneZ constr_from_ptr(long ptr) {
15                 if (bindings.CResult_TrustedClosingTransactionNoneZ_is_ok(ptr)) {
16                         return new Result_TrustedClosingTransactionNoneZ_OK(null, ptr);
17                 } else {
18                         return new Result_TrustedClosingTransactionNoneZ_Err(null, ptr);
19                 }
20         }
21         public class Result_TrustedClosingTransactionNoneZ_OK : Result_TrustedClosingTransactionNoneZ {
22                 public readonly TrustedClosingTransaction res;
23                 internal Result_TrustedClosingTransactionNoneZ_OK(object _dummy, long ptr) : base(_dummy, ptr) {
24                         long res = bindings.CResult_TrustedClosingTransactionNoneZ_get_ok(ptr);
25                         org.ldk.structs.TrustedClosingTransaction res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new org.ldk.structs.TrustedClosingTransaction(null, res); }
26                         if (res_hu_conv != null) { res_hu_conv.ptrs_to.AddLast(this); };
27                         this.res = res_hu_conv;
28                 }
29         }
30
31         public class Result_TrustedClosingTransactionNoneZ_Err : Result_TrustedClosingTransactionNoneZ {
32                 internal Result_TrustedClosingTransactionNoneZ_Err(object _dummy, long ptr) : base(_dummy, ptr) {
33                 }
34         }
35
36         /**
37          * Creates a new CResult_TrustedClosingTransactionNoneZ in the success state.
38          */
39         public static Result_TrustedClosingTransactionNoneZ ok(org.ldk.structs.TrustedClosingTransaction o) {
40                 long ret = bindings.CResult_TrustedClosingTransactionNoneZ_ok(o == null ? 0 : o.ptr);
41                 GC.KeepAlive(o);
42                 if (ret >= 0 && ret <= 4096) { return null; }
43                 Result_TrustedClosingTransactionNoneZ ret_hu_conv = Result_TrustedClosingTransactionNoneZ.constr_from_ptr(ret);
44                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(o); };
45                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
46                 // an object to pass exclusive ownership to the function being called.
47                 // In most cases, we avoid ret_hu_conv being visible in GC'd languages by cloning the object
48                 // at the FFI layer, creating a new object which Rust can claim ownership of
49                 // However, in some cases (eg here), there is no way to clone an object, and thus
50                 // we actually have to pass full ownership to Rust.
51                 // Thus, after ret_hu_conv call, o is reset to null and is now a dummy object.
52                 o.ptr = 0;;
53                 return ret_hu_conv;
54         }
55
56         /**
57          * Creates a new CResult_TrustedClosingTransactionNoneZ in the error state.
58          */
59         public static Result_TrustedClosingTransactionNoneZ err() {
60                 long ret = bindings.CResult_TrustedClosingTransactionNoneZ_err();
61                 if (ret >= 0 && ret <= 4096) { return null; }
62                 Result_TrustedClosingTransactionNoneZ ret_hu_conv = Result_TrustedClosingTransactionNoneZ.constr_from_ptr(ret);
63                 return ret_hu_conv;
64         }
65
66         /**
67          * Checks if the given object is currently in the success state
68          */
69         public bool is_ok() {
70                 bool ret = bindings.CResult_TrustedClosingTransactionNoneZ_is_ok(this.ptr);
71                 GC.KeepAlive(this);
72                 return ret;
73         }
74
75 }
76 } } }