summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadRustRuntime
diff options
context:
space:
mode:
authorJon Petersson <jon.petersson@mullvad.net>2025-03-31 11:45:12 +0200
committerJon Petersson <jon.petersson@mullvad.net>2025-03-31 11:45:12 +0200
commit12b98273d2d3057dfa30d2367d80d3504f3b11e9 (patch)
tree9d5eadcd15c4391e95f223a57db98c5228507d42 /ios/MullvadRustRuntime
parent2640cd40b6a7a2468945b5c4c4be42bbe509c4e5 (diff)
parentb6a47bc377db48f39414d7587995b41bff4f8901 (diff)
downloadmullvadvpn-12b98273d2d3057dfa30d2367d80d3504f3b11e9.tar.xz
mullvadvpn-12b98273d2d3057dfa30d2367d80d3504f3b11e9.zip
Merge branch 'implement-getrelays-using-mullvad-api-ios-1133'
Diffstat (limited to 'ios/MullvadRustRuntime')
-rw-r--r--ios/MullvadRustRuntime/MullvadApiResponse.swift8
-rw-r--r--ios/MullvadRustRuntime/include/mullvad_rust_runtime.h20
2 files changed, 28 insertions, 0 deletions
diff --git a/ios/MullvadRustRuntime/MullvadApiResponse.swift b/ios/MullvadRustRuntime/MullvadApiResponse.swift
index 7836d43971..ddead026b3 100644
--- a/ios/MullvadRustRuntime/MullvadApiResponse.swift
+++ b/ios/MullvadRustRuntime/MullvadApiResponse.swift
@@ -25,6 +25,14 @@ public class MullvadApiResponse {
return Data(UnsafeBufferPointer(start: body, count: Int(response.body_size)))
}
+ public var etag: String? {
+ return if response.etag == nil {
+ nil
+ } else {
+ String(cString: response.etag)
+ }
+ }
+
public var errorDescription: String? {
return if response.error_description == nil {
nil
diff --git a/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h b/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h
index e054de0044..8a199559b5 100644
--- a/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h
+++ b/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h
@@ -43,6 +43,7 @@ typedef struct SwiftRetryStrategy {
typedef struct SwiftMullvadApiResponse {
uint8_t *body;
uintptr_t body_size;
+ uint8_t *etag;
uint16_t status_code;
uint8_t *error_description;
uint8_t *server_response_code;
@@ -114,6 +115,25 @@ struct SwiftCancelHandle mullvad_api_get_addresses(struct SwiftApiContext api_co
struct SwiftRetryStrategy retry_strategy);
/**
+ * # Safety
+ *
+ * `api_context` must be pointing to a valid instance of `SwiftApiContext`. A `SwiftApiContext` is created
+ * by calling `mullvad_api_init_new`.
+ *
+ * `completion_cookie` must be pointing to a valid instance of `CompletionCookie`. `CompletionCookie` is
+ * safe because the pointer in `MullvadApiCompletion` is valid for the lifetime of the process where this
+ * type is intended to be used.
+ *
+ * `etag` must be a pointer to a null terminated string.
+ *
+ * This function is not safe to call multiple times with the same `CompletionCookie`.
+ */
+struct SwiftCancelHandle mullvad_api_get_relays(struct SwiftApiContext api_context,
+ void *completion_cookie,
+ struct SwiftRetryStrategy retry_strategy,
+ const uint8_t *etag);
+
+/**
* Called by the Swift side to signal that a Mullvad API call should be cancelled.
* After this call, the cancel token is no longer valid.
*