[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / PathFailure.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 /**
9  * When the payment path failure took place and extra details about it. [`PathFailure::OnPath`] may
10  * contain a [`NetworkUpdate`] that needs to be applied to the [`NetworkGraph`].
11  * 
12  * [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate
13  * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
14  */
15 public class PathFailure : CommonBase {
16         protected PathFailure(object _dummy, long ptr) : base(ptr) { }
17         ~PathFailure() {
18                 if (ptr != 0) { bindings.PathFailure_free(ptr); }
19         }
20
21         internal static PathFailure constr_from_ptr(long ptr) {
22                 long raw_ty = bindings.LDKPathFailure_ty_from_ptr(ptr);
23                 switch (raw_ty) {
24                         case 0: return new PathFailure_InitialSend(ptr);
25                         case 1: return new PathFailure_OnPath(ptr);
26                         default:
27                                 throw new ArgumentException("Impossible enum variant");
28                 }
29         }
30
31         /** A PathFailure of type InitialSend */
32         public class PathFailure_InitialSend : PathFailure {
33                 /**
34                  * The error surfaced from initial send.
35                  */
36                 public APIError err;
37                 internal PathFailure_InitialSend(long ptr) : base(null, ptr) {
38                         long err = bindings.LDKPathFailure_InitialSend_get_err(ptr);
39                         org.ldk.structs.APIError err_hu_conv = org.ldk.structs.APIError.constr_from_ptr(err);
40                         if (err_hu_conv != null) { err_hu_conv.ptrs_to.AddLast(this); };
41                         this.err = err_hu_conv;
42                 }
43         }
44         /** A PathFailure of type OnPath */
45         public class PathFailure_OnPath : PathFailure {
46                 /**
47                  * If present, this [`NetworkUpdate`] should be applied to the [`NetworkGraph`] so that routing
48                  * decisions can take into account the update.
49                  * 
50                  * [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate
51                  * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
52                  */
53                 public Option_NetworkUpdateZ network_update;
54                 internal PathFailure_OnPath(long ptr) : base(null, ptr) {
55                         long network_update = bindings.LDKPathFailure_OnPath_get_network_update(ptr);
56                         org.ldk.structs.Option_NetworkUpdateZ network_update_hu_conv = org.ldk.structs.Option_NetworkUpdateZ.constr_from_ptr(network_update);
57                         if (network_update_hu_conv != null) { network_update_hu_conv.ptrs_to.AddLast(this); };
58                         this.network_update = network_update_hu_conv;
59                 }
60         }
61         internal long clone_ptr() {
62                 long ret = bindings.PathFailure_clone_ptr(this.ptr);
63                 GC.KeepAlive(this);
64                 return ret;
65         }
66
67         /**
68          * Creates a copy of the PathFailure
69          */
70         public PathFailure clone() {
71                 long ret = bindings.PathFailure_clone(this.ptr);
72                 GC.KeepAlive(this);
73                 if (ret >= 0 && ret <= 4096) { return null; }
74                 org.ldk.structs.PathFailure ret_hu_conv = org.ldk.structs.PathFailure.constr_from_ptr(ret);
75                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
76                 return ret_hu_conv;
77         }
78
79         /**
80          * Utility method to constructs a new InitialSend-variant PathFailure
81          */
82         public static PathFailure initial_send(org.ldk.structs.APIError err) {
83                 long ret = bindings.PathFailure_initial_send(err.ptr);
84                 GC.KeepAlive(err);
85                 if (ret >= 0 && ret <= 4096) { return null; }
86                 org.ldk.structs.PathFailure ret_hu_conv = org.ldk.structs.PathFailure.constr_from_ptr(ret);
87                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
88                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(err); };
89                 return ret_hu_conv;
90         }
91
92         /**
93          * Utility method to constructs a new OnPath-variant PathFailure
94          */
95         public static PathFailure on_path(org.ldk.structs.Option_NetworkUpdateZ network_update) {
96                 long ret = bindings.PathFailure_on_path(network_update.ptr);
97                 GC.KeepAlive(network_update);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 org.ldk.structs.PathFailure ret_hu_conv = org.ldk.structs.PathFailure.constr_from_ptr(ret);
100                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
101                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(network_update); };
102                 return ret_hu_conv;
103         }
104
105         /**
106          * Checks if two PathFailures contain equal inner contents.
107          * This ignores pointers and is_owned flags and looks at the values in fields.
108          */
109         public bool eq(org.ldk.structs.PathFailure b) {
110                 bool ret = bindings.PathFailure_eq(this.ptr, b == null ? 0 : b.ptr);
111                 GC.KeepAlive(this);
112                 GC.KeepAlive(b);
113                 return ret;
114         }
115
116         public override bool Equals(object o) {
117                 if (!(o is PathFailure)) return false;
118                 return this.eq((PathFailure)o);
119         }
120         /**
121          * Serialize the PathFailure object into a byte array which can be read by PathFailure_read
122          */
123         public byte[] write() {
124                 long ret = bindings.PathFailure_write(this.ptr);
125                 GC.KeepAlive(this);
126                 if (ret >= 0 && ret <= 4096) { return null; }
127                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
128                 return ret_conv;
129         }
130
131 }
132 } } }