Initial checkin
[ldk-swift-linux] / LDKSwift / Sources / LDKSwift / structs / Init.swift
1 import LDKCHeaders
2
3 public class Init {
4
5     public internal(set) var cOpaqueStruct: LDKInit?;
6
7         /* DEFAULT_CONSTRUCTOR_START */
8     public init(features_arg: InitFeatures) {
9         
10         self.cOpaqueStruct = Init_new(features_arg.cOpaqueStruct!)
11     }
12     /* DEFAULT_CONSTRUCTOR_END */
13
14     public init(pointer: LDKInit){
15                 self.cOpaqueStruct = pointer
16         }
17
18     /* STRUCT_METHODS_START */
19
20     public func get_features() -> InitFeatures {
21         
22         return InitFeatures(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKInit>) in
23 Init_get_features(this_ptrPointer)
24 });
25     }
26
27     public func set_features(val: InitFeatures) -> Void {
28         
29                                                         let this_ptrPointer = UnsafeMutablePointer<LDKInit>.allocate(capacity: 1)
30                                                         this_ptrPointer.initialize(to: self.cOpaqueStruct!)
31                                                 
32         return Init_set_features(this_ptrPointer, val.cOpaqueStruct!);
33     }
34
35     public func clone(orig: Init) -> Init {
36         
37         return withUnsafePointer(to: orig.cOpaqueStruct!) { (origPointer: UnsafePointer<LDKInit>) in
38 Init(pointer: Init_clone(origPointer))
39 };
40     }
41
42     public func write(obj: Init) -> [UInt8] {
43         
44         return Bindings.LDKCVec_u8Z_to_array(nativeType: withUnsafePointer(to: obj.cOpaqueStruct!) { (objPointer: UnsafePointer<LDKInit>) in
45 Init_write(objPointer)
46 });
47     }
48
49     public func read(ser: [UInt8]) -> Result_InitDecodeErrorZ {
50         
51         return Result_InitDecodeErrorZ(pointer: Init_read(Bindings.new_LDKu8slice(array: ser)));
52     }
53
54                                 
55         deinit {
56                                         if self.cOpaqueStruct?.is_owned == false {
57
58                                         
59                                         
60                 Init_free(self.cOpaqueStruct!)
61                                         
62 }
63                                 
64         }
65                         
66     /* STRUCT_METHODS_END */
67
68 }