Skip to content

Commit

Permalink
update bindings generation with options suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
arik-so committed May 28, 2021
1 parent e8d92c6 commit 9ecb278
Show file tree
Hide file tree
Showing 19 changed files with 2,151 additions and 384 deletions.
757 changes: 387 additions & 370 deletions bindings/LDK/Bindings.swift

Large diffs are not rendered by default.

127 changes: 127 additions & 0 deletions bindings/LDK/options/APIError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,133 @@ public class APIError {

/* OPTION_METHODS_START */

public enum APIErrorValueType {
case APIMisuseError, FeeRateTooHigh, RouteError, ChannelUnavailable
}

public func getValueType() -> APIErrorValueType? {
switch self.cOpaqueStruct?.tag {

case LDKAPIError_APIMisuseError:
return .APIMisuseError
case LDKAPIError_FeeRateTooHigh:
return .FeeRateTooHigh
case LDKAPIError_RouteError:
return .RouteError
case LDKAPIError_ChannelUnavailable:
return .ChannelUnavailable
default:
return nil
}
}


public func getValueAsAPIMisuseError() -> APIMisuseError? {
if self.cOpaqueStruct?.tag != LDKAPIError_APIMisuseError {
return nil
}
return APIMisuseError(pointer: self.cOpaqueStruct!.api_misuse_error)
}

public func getValueAsFeeRateTooHigh() -> FeeRateTooHigh? {
if self.cOpaqueStruct?.tag != LDKAPIError_FeeRateTooHigh {
return nil
}
return FeeRateTooHigh(pointer: self.cOpaqueStruct!.fee_rate_too_high)
}

public func getValueAsRouteError() -> RouteError? {
if self.cOpaqueStruct?.tag != LDKAPIError_RouteError {
return nil
}
return RouteError(pointer: self.cOpaqueStruct!.route_error)
}

public func getValueAsChannelUnavailable() -> ChannelUnavailable? {
if self.cOpaqueStruct?.tag != LDKAPIError_ChannelUnavailable {
return nil
}
return ChannelUnavailable(pointer: self.cOpaqueStruct!.channel_unavailable)
}


/* OPTION_METHODS_END */



public class APIMisuseError {


var cOpaqueStruct: LDKAPIError_LDKAPIMisuseError_Body?;
fileprivate init(pointer: LDKAPIError_LDKAPIMisuseError_Body) {
self.cOpaqueStruct = pointer
}



public func getErr() -> String {
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
}


}


public class FeeRateTooHigh {


var cOpaqueStruct: LDKAPIError_LDKFeeRateTooHigh_Body?;
fileprivate init(pointer: LDKAPIError_LDKFeeRateTooHigh_Body) {
self.cOpaqueStruct = pointer
}



public func getErr() -> String {
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
}

public func getFeerate() -> UInt32 {
return self.cOpaqueStruct!.feerate
}


}


public class RouteError {


var cOpaqueStruct: LDKAPIError_LDKRouteError_Body?;
fileprivate init(pointer: LDKAPIError_LDKRouteError_Body) {
self.cOpaqueStruct = pointer
}



public func getErr() -> String {
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
}


}


public class ChannelUnavailable {


var cOpaqueStruct: LDKAPIError_LDKChannelUnavailable_Body?;
fileprivate init(pointer: LDKAPIError_LDKChannelUnavailable_Body) {
self.cOpaqueStruct = pointer
}



public func getErr() -> String {
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
}


}

}
69 changes: 69 additions & 0 deletions bindings/LDK/options/ErrorAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,75 @@ public class ErrorAction {

/* OPTION_METHODS_START */

public enum ErrorActionValueType {
case DisconnectPeer, SendErrorMessage
}

public func getValueType() -> ErrorActionValueType? {
switch self.cOpaqueStruct?.tag {

case LDKErrorAction_DisconnectPeer:
return .DisconnectPeer
case LDKErrorAction_SendErrorMessage:
return .SendErrorMessage
default:
return nil
}
}


public func getValueAsDisconnectPeer() -> DisconnectPeer? {
if self.cOpaqueStruct?.tag != LDKErrorAction_DisconnectPeer {
return nil
}
return DisconnectPeer(pointer: self.cOpaqueStruct!.disconnect_peer)
}

public func getValueAsSendErrorMessage() -> SendErrorMessage? {
if self.cOpaqueStruct?.tag != LDKErrorAction_SendErrorMessage {
return nil
}
return SendErrorMessage(pointer: self.cOpaqueStruct!.send_error_message)
}


/* OPTION_METHODS_END */



public class DisconnectPeer {


var cOpaqueStruct: LDKErrorAction_LDKDisconnectPeer_Body?;
fileprivate init(pointer: LDKErrorAction_LDKDisconnectPeer_Body) {
self.cOpaqueStruct = pointer
}



public func getMsg() -> ErrorMessage {
return ErrorMessage(pointer: self.cOpaqueStruct!.msg)
}


}


public class SendErrorMessage {


var cOpaqueStruct: LDKErrorAction_LDKSendErrorMessage_Body?;
fileprivate init(pointer: LDKErrorAction_LDKSendErrorMessage_Body) {
self.cOpaqueStruct = pointer
}



public func getMsg() -> ErrorMessage {
return ErrorMessage(pointer: self.cOpaqueStruct!.msg)
}


}

}
Loading

0 comments on commit 9ecb278

Please sign in to comment.