Initial checkin
[ldk-swift-linux] / LDKSwift / Sources / LDKSwift / options / APIError.swift
1 import LDKCHeaders
2
3 public class APIError {
4
5     public internal(set) var cOpaqueStruct: LDKAPIError?;
6
7         
8
9     public init(pointer: LDKAPIError){
10                 self.cOpaqueStruct = pointer
11         }
12
13     /* OPTION_METHODS_START */
14
15                                 public enum APIErrorValueType {
16                                         case APIMisuseError, FeeRateTooHigh, RouteError, ChannelUnavailable
17                                 }
18                                 
19                                 public func getValueType() -> APIErrorValueType? {
20                                         switch self.cOpaqueStruct?.tag {
21                     
22                                         case LDKAPIError_APIMisuseError:
23                                                 return .APIMisuseError
24                                         case LDKAPIError_FeeRateTooHigh:
25                                                 return .FeeRateTooHigh
26                                         case LDKAPIError_RouteError:
27                                                 return .RouteError
28                                         case LDKAPIError_ChannelUnavailable:
29                                                 return .ChannelUnavailable
30                     default:
31                         return nil
32                     }
33                                 }
34                                 
35                                 
36                                         public func getValueAsAPIMisuseError() -> APIMisuseError? {
37                                                 if self.cOpaqueStruct?.tag != LDKAPIError_APIMisuseError {
38                                                         return nil
39                                                 }
40                                                 return APIMisuseError(pointer: self.cOpaqueStruct!.api_misuse_error)
41                                         }
42                                 
43                                         public func getValueAsFeeRateTooHigh() -> FeeRateTooHigh? {
44                                                 if self.cOpaqueStruct?.tag != LDKAPIError_FeeRateTooHigh {
45                                                         return nil
46                                                 }
47                                                 return FeeRateTooHigh(pointer: self.cOpaqueStruct!.fee_rate_too_high)
48                                         }
49                                 
50                                         public func getValueAsRouteError() -> RouteError? {
51                                                 if self.cOpaqueStruct?.tag != LDKAPIError_RouteError {
52                                                         return nil
53                                                 }
54                                                 return RouteError(pointer: self.cOpaqueStruct!.route_error)
55                                         }
56                                 
57                                         public func getValueAsChannelUnavailable() -> ChannelUnavailable? {
58                                                 if self.cOpaqueStruct?.tag != LDKAPIError_ChannelUnavailable {
59                                                         return nil
60                                                 }
61                                                 return ChannelUnavailable(pointer: self.cOpaqueStruct!.channel_unavailable)
62                                         }
63                                 
64                         
65     /* OPTION_METHODS_END */
66
67         
68
69                         public class APIMisuseError {
70                                 
71                                 
72                                 var cOpaqueStruct: LDKAPIError_LDKAPIMisuseError_Body?;
73                                 fileprivate init(pointer: LDKAPIError_LDKAPIMisuseError_Body) {
74                                         self.cOpaqueStruct = pointer
75                                 }
76                         
77                                 
78                                 
79                                         public func getErr() -> String {
80                                                 return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
81                                         }
82                                 
83                                 
84                         }
85                 
86
87                         public class FeeRateTooHigh {
88                                 
89                                 
90                                 var cOpaqueStruct: LDKAPIError_LDKFeeRateTooHigh_Body?;
91                                 fileprivate init(pointer: LDKAPIError_LDKFeeRateTooHigh_Body) {
92                                         self.cOpaqueStruct = pointer
93                                 }
94                         
95                                 
96                                 
97                                         public func getErr() -> String {
98                                                 return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
99                                         }
100                                 
101                                         public func getFeerate() -> UInt32 {
102                                                 return self.cOpaqueStruct!.feerate
103                                         }
104                                 
105                                 
106                         }
107                 
108
109                         public class RouteError {
110                                 
111                                 
112                                 var cOpaqueStruct: LDKAPIError_LDKRouteError_Body?;
113                                 fileprivate init(pointer: LDKAPIError_LDKRouteError_Body) {
114                                         self.cOpaqueStruct = pointer
115                                 }
116                         
117                                 
118                                 
119                                         public func getErr() -> String {
120                                                 return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
121                                         }
122                                 
123                                 
124                         }
125                 
126
127                         public class ChannelUnavailable {
128                                 
129                                 
130                                 var cOpaqueStruct: LDKAPIError_LDKChannelUnavailable_Body?;
131                                 fileprivate init(pointer: LDKAPIError_LDKChannelUnavailable_Body) {
132                                         self.cOpaqueStruct = pointer
133                                 }
134                         
135                                 
136                                 
137                                         public func getErr() -> String {
138                                                 return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
139                                         }
140                                 
141                                 
142                         }
143                 
144 }