[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / Persister.cs
1
2 using org.ldk.impl;
3 using org.ldk.enums;
4 using org.ldk.util;
5 using System;
6
7 namespace org { namespace ldk { namespace structs {
8
9
10
11 /** An implementation of Persister */
12 public interface PersisterInterface {
13         /**Persist the given ['ChannelManager'] to disk, returning an error if persistence failed.
14          * 
15          * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
16          */
17         Result_NoneIOErrorZ persist_manager(ChannelManager channel_manager);
18         /**Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed.
19          */
20         Result_NoneIOErrorZ persist_graph(NetworkGraph network_graph);
21         /**Persist the given [`WriteableScore`] to disk, returning an error if persistence failed.
22          */
23         Result_NoneIOErrorZ persist_scorer(WriteableScore scorer);
24 }
25
26 /**
27  * Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk.
28  * 
29  * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
30  */
31 public class Persister : CommonBase {
32         internal bindings.LDKPersister bindings_instance;
33         internal long instance_idx;
34
35         internal Persister(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
36         ~Persister() {
37                 if (ptr != 0) { bindings.Persister_free(ptr); }
38         }
39
40         private class LDKPersisterHolder { internal Persister held; }
41         private class LDKPersisterImpl : bindings.LDKPersister {
42                 internal LDKPersisterImpl(PersisterInterface arg, LDKPersisterHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
43                 private PersisterInterface arg;
44                 private LDKPersisterHolder impl_holder;
45                 public long persist_manager(long _channel_manager) {
46                         org.ldk.structs.ChannelManager _channel_manager_hu_conv = null; if (_channel_manager < 0 || _channel_manager > 4096) { _channel_manager_hu_conv = new org.ldk.structs.ChannelManager(null, _channel_manager); }
47                         Result_NoneIOErrorZ ret = arg.persist_manager(_channel_manager_hu_conv);
48                                 GC.KeepAlive(arg);
49                         long result = ret.clone_ptr();
50                         return result;
51                 }
52                 public long persist_graph(long _network_graph) {
53                         org.ldk.structs.NetworkGraph _network_graph_hu_conv = null; if (_network_graph < 0 || _network_graph > 4096) { _network_graph_hu_conv = new org.ldk.structs.NetworkGraph(null, _network_graph); }
54                         Result_NoneIOErrorZ ret = arg.persist_graph(_network_graph_hu_conv);
55                                 GC.KeepAlive(arg);
56                         long result = ret.clone_ptr();
57                         return result;
58                 }
59                 public long persist_scorer(long _scorer) {
60                         WriteableScore ret_hu_conv = new WriteableScore(null, _scorer);
61                         if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
62                         Result_NoneIOErrorZ ret = arg.persist_scorer(ret_hu_conv);
63                                 GC.KeepAlive(arg);
64                         long result = ret.clone_ptr();
65                         return result;
66                 }
67         }
68
69         /** Creates a new instance of Persister from a given implementation */
70         public static Persister new_impl(PersisterInterface arg) {
71                 LDKPersisterHolder impl_holder = new LDKPersisterHolder();
72                 LDKPersisterImpl impl = new LDKPersisterImpl(arg, impl_holder);
73                 long[] ptr_idx = bindings.LDKPersister_new(impl);
74
75                 impl_holder.held = new Persister(null, ptr_idx[0]);
76                 impl_holder.held.instance_idx = ptr_idx[1];
77                 impl_holder.held.bindings_instance = impl;
78                 return impl_holder.held;
79         }
80
81         /**
82          * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed.
83          * 
84          * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
85          */
86         public Result_NoneIOErrorZ persist_manager(org.ldk.structs.ChannelManager channel_manager) {
87                 long ret = bindings.Persister_persist_manager(this.ptr, channel_manager.ptr);
88                 GC.KeepAlive(this);
89                 GC.KeepAlive(channel_manager);
90                 if (ret >= 0 && ret <= 4096) { return null; }
91                 Result_NoneIOErrorZ ret_hu_conv = Result_NoneIOErrorZ.constr_from_ptr(ret);
92                 if (this != null) { this.ptrs_to.AddLast(channel_manager); };
93                 return ret_hu_conv;
94         }
95
96         /**
97          * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed.
98          */
99         public Result_NoneIOErrorZ persist_graph(org.ldk.structs.NetworkGraph network_graph) {
100                 long ret = bindings.Persister_persist_graph(this.ptr, network_graph.ptr);
101                 GC.KeepAlive(this);
102                 GC.KeepAlive(network_graph);
103                 if (ret >= 0 && ret <= 4096) { return null; }
104                 Result_NoneIOErrorZ ret_hu_conv = Result_NoneIOErrorZ.constr_from_ptr(ret);
105                 if (this != null) { this.ptrs_to.AddLast(network_graph); };
106                 return ret_hu_conv;
107         }
108
109         /**
110          * Persist the given [`WriteableScore`] to disk, returning an error if persistence failed.
111          */
112         public Result_NoneIOErrorZ persist_scorer(org.ldk.structs.WriteableScore scorer) {
113                 long ret = bindings.Persister_persist_scorer(this.ptr, scorer.ptr);
114                 GC.KeepAlive(this);
115                 GC.KeepAlive(scorer);
116                 if (ret >= 0 && ret <= 4096) { return null; }
117                 Result_NoneIOErrorZ ret_hu_conv = Result_NoneIOErrorZ.constr_from_ptr(ret);
118                 if (this != null) { this.ptrs_to.AddLast(scorer); };
119                 return ret_hu_conv;
120         }
121
122 }
123 } } }