Initial checkin
[ldk-swift-linux] / LDKSwift / Sources / LDKSwift / traits / Persist.swift
1 import LDKCHeaders
2 import LDKCHeaders
3 open class Persist {
4
5     public var cOpaqueStruct: LDKPersist?;
6
7     public init() {
8
9         /* NATIVE_CALLBACKS_START */
10
11                 func persist_new_channelCallback(pointer: UnsafeRawPointer?, id: LDKOutPoint, dataPointer: UnsafePointer<LDKChannelMonitor>) -> LDKCResult_NoneChannelMonitorUpdateErrZ {
12                         let instance: Persist = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "Persist.swift::persist_new_channel")
13                         let data = ChannelMonitor(pointer: dataPointer.pointee);
14
15                         return instance.persist_new_channel(id: OutPoint(pointer: id), data: data).cOpaqueStruct!;
16                 }
17
18                 func update_persisted_channelCallback(pointer: UnsafeRawPointer?, id: LDKOutPoint, updatePointer: UnsafePointer<LDKChannelMonitorUpdate>, dataPointer: UnsafePointer<LDKChannelMonitor>) -> LDKCResult_NoneChannelMonitorUpdateErrZ {
19                         let instance: Persist = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "Persist.swift::update_persisted_channel")
20                         let update = ChannelMonitorUpdate(pointer: updatePointer.pointee);
21 let data = ChannelMonitor(pointer: dataPointer.pointee);
22
23                         return instance.update_persisted_channel(id: OutPoint(pointer: id), update: update, data: data).cOpaqueStruct!;
24                 }
25
26                 func freeCallback(pointer: UnsafeMutableRawPointer?) -> Void {
27                         let instance: Persist = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "Persist.swift::free")
28                         
29                         return instance.free();
30                 }
31
32                 /* NATIVE_CALLBACKS_END */
33
34         self.cOpaqueStruct = LDKPersist(this_arg: Bindings.instanceToPointer(instance: self), 
35                         persist_new_channel: persist_new_channelCallback,
36                         update_persisted_channel: update_persisted_channelCallback,
37                         free: freeCallback)
38     }
39
40     public init(pointer: LDKPersist){
41                 self.cOpaqueStruct = pointer
42         }
43
44     /* SWIFT_CALLBACKS_START */
45
46     open func persist_new_channel(id: OutPoint, data: ChannelMonitor) -> Result_NoneChannelMonitorUpdateErrZ {
47         /* EDIT ME */
48                 return Result_NoneChannelMonitorUpdateErrZ(pointer: LDKCResult_NoneChannelMonitorUpdateErrZ())
49     }
50
51     open func update_persisted_channel(id: OutPoint, update: ChannelMonitorUpdate, data: ChannelMonitor) -> Result_NoneChannelMonitorUpdateErrZ {
52         /* EDIT ME */
53                 return Result_NoneChannelMonitorUpdateErrZ(pointer: LDKCResult_NoneChannelMonitorUpdateErrZ())
54     }
55
56     open func free() -> Void {
57         /* EDIT ME */
58                 
59     }
60
61     /* SWIFT_CALLBACKS_END */
62
63 }
64
65
66 public class NativelyImplementedPersist: Persist {
67         /* SWIFT_DEFAULT_CALLBACKS_START */
68
69         public override func persist_new_channel(id: OutPoint, data: ChannelMonitor) -> Result_NoneChannelMonitorUpdateErrZ {
70                 
71                                 return withUnsafePointer(to: data.cOpaqueStruct!) { (dataPointer: UnsafePointer<LDKChannelMonitor>) in
72
73                                 Result_NoneChannelMonitorUpdateErrZ(pointer: self.cOpaqueStruct!.persist_new_channel(self.cOpaqueStruct!.this_arg, id.cOpaqueStruct!, dataPointer))
74                                 
75 }
76                         
77         }
78
79         public override func update_persisted_channel(id: OutPoint, update: ChannelMonitorUpdate, data: ChannelMonitor) -> Result_NoneChannelMonitorUpdateErrZ {
80                 
81                                 return withUnsafePointer(to: update.cOpaqueStruct!) { (updatePointer: UnsafePointer<LDKChannelMonitorUpdate>) in
82 withUnsafePointer(to: data.cOpaqueStruct!) { (dataPointer: UnsafePointer<LDKChannelMonitor>) in
83
84                                 Result_NoneChannelMonitorUpdateErrZ(pointer: self.cOpaqueStruct!.update_persisted_channel(self.cOpaqueStruct!.this_arg, id.cOpaqueStruct!, updatePointer, dataPointer))
85                                 
86 }
87 }
88                         
89         }
90
91         public override func free() -> Void {
92                 
93                                 
94                                 self.cOpaqueStruct!.free(self.cOpaqueStruct!.this_arg)
95                                 
96                         
97         }
98
99         /* SWIFT_DEFAULT_CALLBACKS_END */
100 }