6 namespace org { namespace ldk { namespace structs {
9 * Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk.
11 public class Persister : CommonBase {
12 internal readonly bindings.LDKPersister bindings_instance;
13 internal Persister(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
14 private Persister(bindings.LDKPersister arg) : base(bindings.LDKPersister_new(arg)) {
15 this.ptrs_to.AddLast(arg);
16 this.bindings_instance = arg;
19 if (ptr != 0) { bindings.Persister_free(ptr); }
22 public interface PersisterInterface {
24 * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed.
26 Result_NoneErrorZ persist_manager(ChannelManager _channel_manager);
28 * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed.
30 Result_NoneErrorZ persist_graph(NetworkGraph _network_graph);
32 * Persist the given [`WriteableScore`] to disk, returning an error if persistence failed.
34 Result_NoneErrorZ persist_scorer(WriteableScore _scorer);
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_NoneErrorZ ret = arg.persist_manager(_channel_manager_hu_conv);
45 long result = ret == null ? 0 : ret.clone_ptr();
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_NoneErrorZ ret = arg.persist_graph(_network_graph_hu_conv);
52 long result = ret == null ? 0 : ret.clone_ptr();
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_NoneErrorZ ret = arg.persist_scorer(ret_hu_conv);
60 long result = ret == null ? 0 : ret.clone_ptr();
64 public static Persister new_impl(PersisterInterface arg) {
65 LDKPersisterHolder impl_holder = new LDKPersisterHolder();
66 impl_holder.held = new Persister(new LDKPersisterImpl(arg, impl_holder));
67 return impl_holder.held;
70 * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed.
72 public Result_NoneErrorZ persist_manager(org.ldk.structs.ChannelManager channel_manager) {
73 long ret = bindings.Persister_persist_manager(this.ptr, channel_manager == null ? 0 : channel_manager.ptr);
75 GC.KeepAlive(channel_manager);
76 if (ret >= 0 && ret <= 4096) { return null; }
77 Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
78 if (this != null) { this.ptrs_to.AddLast(channel_manager); };
83 * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed.
85 public Result_NoneErrorZ persist_graph(org.ldk.structs.NetworkGraph network_graph) {
86 long ret = bindings.Persister_persist_graph(this.ptr, network_graph == null ? 0 : network_graph.ptr);
88 GC.KeepAlive(network_graph);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
91 if (this != null) { this.ptrs_to.AddLast(network_graph); };
96 * Persist the given [`WriteableScore`] to disk, returning an error if persistence failed.
98 public Result_NoneErrorZ persist_scorer(org.ldk.structs.WriteableScore scorer) {
99 long ret = bindings.Persister_persist_scorer(this.ptr, scorer == null ? 0 : scorer.ptr);
101 GC.KeepAlive(scorer);
102 if (ret >= 0 && ret <= 4096) { return null; }
103 Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
104 if (this != null) { this.ptrs_to.AddLast(scorer); };