summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadRustRuntime
diff options
context:
space:
mode:
authorAndrew Bulhak <andrew.bulhak@mullvad.net>2025-07-31 16:08:26 +0200
committerAndrew Bulhak <andrew.bulhak@mullvad.net>2025-08-04 15:41:28 +0200
commitab927b72ac7337ccc048057954bb2858370a907f (patch)
tree7e571b72a931103c231cd1e97dfd4318a52f7606 /ios/MullvadRustRuntime
parent44d47dd4c360e644df505460e7a79ba09849d82b (diff)
downloadmullvadvpn-ab927b72ac7337ccc048057954bb2858370a907f.tar.xz
mullvadvpn-ab927b72ac7337ccc048057954bb2858370a907f.zip
Make the code more concise/idiomatic/better organised
Diffstat (limited to 'ios/MullvadRustRuntime')
-rw-r--r--ios/MullvadRustRuntime/MullvadApiContext.swift4
-rw-r--r--ios/MullvadRustRuntime/MullvadApiResponse.swift18
2 files changed, 5 insertions, 17 deletions
diff --git a/ios/MullvadRustRuntime/MullvadApiContext.swift b/ios/MullvadRustRuntime/MullvadApiContext.swift
index bd89ab891f..7600b79e70 100644
--- a/ios/MullvadRustRuntime/MullvadApiContext.swift
+++ b/ios/MullvadRustRuntime/MullvadApiContext.swift
@@ -9,7 +9,7 @@
import MullvadTypes
public struct MullvadApiContext: @unchecked Sendable {
- enum MullvadApiContextError: Error {
+ enum Error: Swift.Error {
case failedToConstructApiClient
}
@@ -58,7 +58,7 @@ public struct MullvadApiContext: @unchecked Sendable {
}
if context._0 == nil {
- throw MullvadApiContextError.failedToConstructApiClient
+ throw Error.failedToConstructApiClient
}
}
}
diff --git a/ios/MullvadRustRuntime/MullvadApiResponse.swift b/ios/MullvadRustRuntime/MullvadApiResponse.swift
index ddead026b3..597de40b75 100644
--- a/ios/MullvadRustRuntime/MullvadApiResponse.swift
+++ b/ios/MullvadRustRuntime/MullvadApiResponse.swift
@@ -26,19 +26,11 @@ public class MullvadApiResponse {
}
public var etag: String? {
- return if response.etag == nil {
- nil
- } else {
- String(cString: response.etag)
- }
+ response.etag.map { String(cString: $0) }
}
public var errorDescription: String? {
- return if response.error_description == nil {
- nil
- } else {
- String(cString: response.error_description)
- }
+ response.error_description.map { String(cString: $0) }
}
public var statusCode: UInt16 {
@@ -46,11 +38,7 @@ public class MullvadApiResponse {
}
public var serverResponseCode: String? {
- return if response.server_response_code == nil {
- nil
- } else {
- String(cString: response.server_response_code)
- }
+ response.server_response_code.map { String(cString: $0) }
}
public var success: Bool {