eddf38aecb08747ca86a31bf1e0d103d09c78f9e
[ldk-java] / c_sharp / src / org / ldk / structs / Result_NetworkGraphDecodeErrorZ.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_NetworkGraphDecodeErrorZ : CommonBase {
9         Result_NetworkGraphDecodeErrorZ(object _dummy, long ptr) : base(ptr) { }
10         ~Result_NetworkGraphDecodeErrorZ() {
11                 if (ptr != 0) { bindings.CResult_NetworkGraphDecodeErrorZ_free(ptr); }
12         }
13
14         internal static Result_NetworkGraphDecodeErrorZ constr_from_ptr(long ptr) {
15                 if (bindings.CResult_NetworkGraphDecodeErrorZ_is_ok(ptr)) {
16                         return new Result_NetworkGraphDecodeErrorZ_OK(null, ptr);
17                 } else {
18                         return new Result_NetworkGraphDecodeErrorZ_Err(null, ptr);
19                 }
20         }
21         public class Result_NetworkGraphDecodeErrorZ_OK : Result_NetworkGraphDecodeErrorZ {
22                 public readonly NetworkGraph res;
23                 internal Result_NetworkGraphDecodeErrorZ_OK(object _dummy, long ptr) : base(_dummy, ptr) {
24                         long res = bindings.CResult_NetworkGraphDecodeErrorZ_get_ok(ptr);
25                         org.ldk.structs.NetworkGraph res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new org.ldk.structs.NetworkGraph(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_NetworkGraphDecodeErrorZ_Err : Result_NetworkGraphDecodeErrorZ {
32                 public readonly DecodeError err;
33                 internal Result_NetworkGraphDecodeErrorZ_Err(object _dummy, long ptr) : base(_dummy, ptr) {
34                         long err = bindings.CResult_NetworkGraphDecodeErrorZ_get_err(ptr);
35                         org.ldk.structs.DecodeError err_hu_conv = org.ldk.structs.DecodeError.constr_from_ptr(err);
36                         if (err_hu_conv != null) { err_hu_conv.ptrs_to.AddLast(this); };
37                         this.err = err_hu_conv;
38                 }
39         }
40
41         /**
42          * Creates a new CResult_NetworkGraphDecodeErrorZ in the success state.
43          */
44         public static Result_NetworkGraphDecodeErrorZ ok(byte[] o_genesis_hash, Logger o_logger) {
45                 long ret = bindings.CResult_NetworkGraphDecodeErrorZ_ok(bindings.NetworkGraph_new(InternalUtils.check_arr_len(o_genesis_hash, 32), o_logger == null ? 0 : o_logger.ptr));
46                 GC.KeepAlive(o_genesis_hash);
47                 GC.KeepAlive(o_logger);
48                 if (ret >= 0 && ret <= 4096) { return null; }
49                 Result_NetworkGraphDecodeErrorZ ret_hu_conv = Result_NetworkGraphDecodeErrorZ.constr_from_ptr(ret);
50                 ;
51                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(o_logger); };
52                 return ret_hu_conv;
53         }
54
55         /**
56          * Creates a new CResult_NetworkGraphDecodeErrorZ in the error state.
57          */
58         public static Result_NetworkGraphDecodeErrorZ err(org.ldk.structs.DecodeError e) {
59                 long ret = bindings.CResult_NetworkGraphDecodeErrorZ_err(e.ptr);
60                 GC.KeepAlive(e);
61                 if (ret >= 0 && ret <= 4096) { return null; }
62                 Result_NetworkGraphDecodeErrorZ ret_hu_conv = Result_NetworkGraphDecodeErrorZ.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_NetworkGraphDecodeErrorZ_is_ok(this.ptr);
71                 GC.KeepAlive(this);
72                 return ret;
73         }
74
75 }
76 } } }