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