summaryrefslogtreecommitdiffhomepage
path: root/ios
diff options
context:
space:
mode:
authormojganii <mojgan.jelodar@codic.se>2025-04-15 12:50:54 +0200
committermojganii <mojgan.jelodar@codic.se>2025-04-15 15:38:45 +0200
commit14db956bcd66b841734ed86b647e95f69034bffe (patch)
treed0f5fa50299da5bfeb65ed591e6c16c70e5cc4dc /ios
parent9eab3722f672e8073218c9ce81999945ef095794 (diff)
downloadmullvadvpn-14db956bcd66b841734ed86b647e95f69034bffe.tar.xz
mullvadvpn-14db956bcd66b841734ed86b647e95f69034bffe.zip
Fix namespace clashing in rust code
Diffstat (limited to 'ios')
-rw-r--r--ios/MullvadREST/MullvadAPI/MullvadApiRequestFactory.swift12
-rw-r--r--ios/MullvadRustRuntime/include/mullvad_rust_runtime.h24
-rw-r--r--ios/MullvadVPNTests/MullvadREST/MullvadApi/RustProblemReportRequestTests.swift6
3 files changed, 19 insertions, 23 deletions
diff --git a/ios/MullvadREST/MullvadAPI/MullvadApiRequestFactory.swift b/ios/MullvadREST/MullvadAPI/MullvadApiRequestFactory.swift
index 647b1b71be..0b3271c80b 100644
--- a/ios/MullvadREST/MullvadAPI/MullvadApiRequestFactory.swift
+++ b/ios/MullvadREST/MullvadAPI/MullvadApiRequestFactory.swift
@@ -26,14 +26,14 @@ public struct MullvadApiRequestFactory: Sendable {
switch request {
case let .getAddressList(retryStrategy):
- return MullvadApiCancellable(handle: mullvad_api_get_addresses(
+ return MullvadApiCancellable(handle: mullvad_ios_get_addresses(
apiContext.context,
rawCompletionPointer,
retryStrategy.toRustStrategy()
))
case let .getRelayList(retryStrategy, etag: etag):
- return MullvadApiCancellable(handle: mullvad_api_get_relays(
+ return MullvadApiCancellable(handle: mullvad_ios_get_relays(
apiContext.context,
rawCompletionPointer,
retryStrategy.toRustStrategy(),
@@ -41,27 +41,27 @@ public struct MullvadApiRequestFactory: Sendable {
))
case let .sendProblemReport(retryStrategy, problemReportRequest):
let rustRequest = RustProblemReportRequest(from: problemReportRequest)
- return MullvadApiCancellable(handle: mullvad_api_send_problem_report(
+ return MullvadApiCancellable(handle: mullvad_ios_send_problem_report(
apiContext.context,
rawCompletionPointer,
retryStrategy.toRustStrategy(),
rustRequest.toRust()
))
case let .getAccount(retryStrategy, accountNumber: accountNumber):
- return MullvadApiCancellable(handle: mullvad_api_get_account(
+ return MullvadApiCancellable(handle: mullvad_ios_get_account(
apiContext.context,
rawCompletionPointer,
retryStrategy.toRustStrategy(),
accountNumber
))
case let .createAccount(retryStrategy):
- return MullvadApiCancellable(handle: mullvad_api_create_account(
+ return MullvadApiCancellable(handle: mullvad_ios_create_account(
apiContext.context,
rawCompletionPointer,
retryStrategy.toRustStrategy()
))
case let .deleteAccount(retryStrategy, accountNumber: accountNumber):
- return MullvadApiCancellable(handle: mullvad_api_delete_account(
+ return MullvadApiCancellable(handle: mullvad_ios_delete_account(
apiContext.context,
rawCompletionPointer,
retryStrategy.toRustStrategy(),
diff --git a/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h b/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h
index bb87b1baa7..36774f2d4e 100644
--- a/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h
+++ b/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h
@@ -125,7 +125,7 @@ struct SwiftApiContext mullvad_api_init_new(const uint8_t *host,
*
* This function is not safe to call multiple times with the same `CompletionCookie`.
*/
-struct SwiftCancelHandle mullvad_api_get_account(struct SwiftApiContext api_context,
+struct SwiftCancelHandle mullvad_ios_get_account(struct SwiftApiContext api_context,
void *completion_cookie,
struct SwiftRetryStrategy retry_strategy,
const char *account_number);
@@ -142,7 +142,7 @@ struct SwiftCancelHandle mullvad_api_get_account(struct SwiftApiContext api_cont
*
* This function is not safe to call multiple times with the same `CompletionCookie`.
*/
-struct SwiftCancelHandle mullvad_api_create_account(struct SwiftApiContext api_context,
+struct SwiftCancelHandle mullvad_ios_create_account(struct SwiftApiContext api_context,
void *completion_cookie,
struct SwiftRetryStrategy retry_strategy);
@@ -160,7 +160,7 @@ struct SwiftCancelHandle mullvad_api_create_account(struct SwiftApiContext api_c
*
* This function is not safe to call multiple times with the same `CompletionCookie`.
*/
-struct SwiftCancelHandle mullvad_api_delete_account(struct SwiftApiContext api_context,
+struct SwiftCancelHandle mullvad_ios_delete_account(struct SwiftApiContext api_context,
void *completion_cookie,
struct SwiftRetryStrategy retry_strategy,
const char *account_number);
@@ -177,7 +177,7 @@ struct SwiftCancelHandle mullvad_api_delete_account(struct SwiftApiContext api_c
*
* This function is not safe to call multiple times with the same `CompletionCookie`.
*/
-struct SwiftCancelHandle mullvad_api_get_addresses(struct SwiftApiContext api_context,
+struct SwiftCancelHandle mullvad_ios_get_addresses(struct SwiftApiContext api_context,
void *completion_cookie,
struct SwiftRetryStrategy retry_strategy);
@@ -195,7 +195,7 @@ struct SwiftCancelHandle mullvad_api_get_addresses(struct SwiftApiContext api_co
*
* This function is not safe to call multiple times with the same `CompletionCookie`.
*/
-struct SwiftCancelHandle mullvad_api_get_relays(struct SwiftApiContext api_context,
+struct SwiftCancelHandle mullvad_ios_get_relays(struct SwiftApiContext api_context,
void *completion_cookie,
struct SwiftRetryStrategy retry_strategy,
const char *etag);
@@ -245,19 +245,15 @@ extern void mullvad_api_completion_finish(struct SwiftMullvadApiResponse respons
* `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.
+ * This function takes ownership of `completion_cookie`, which must be pointing to a valid instance of Swift
+ * object `MullvadApiCompletion`. The pointer will be freed by calling `mullvad_api_completion_finish`
+ * when completion finishes (in completion.finish).
*
* the string properties of `SwiftProblemReportRequest` must be pointers to a null terminated strings.
*
* This function is not safe to call multiple times with the same `CompletionCookie`.
- *
- * Ownership of the `CompletionCookie` is transferred to the Rust side upon calling this function.
- * After this call, the pointer must be considered invalid and must not be reused or accessed in any way.
- * Calling this function again with the same cookie, either sequentially or concurrently, results in undefined behavior.
*/
-struct SwiftCancelHandle mullvad_api_send_problem_report(struct SwiftApiContext api_context,
+struct SwiftCancelHandle mullvad_ios_send_problem_report(struct SwiftApiContext api_context,
void *completion_cookie,
struct SwiftRetryStrategy retry_strategy,
struct SwiftProblemReportRequest request);
@@ -269,7 +265,7 @@ struct ProblemReportMetadata swift_problem_report_metadata_new(void);
*
* # Safety
*
- * `self` must be a valid, exclusive pointer to `ProblemReportMetadata`, initialized
+ * `map.inner` must be non-null and point to a valid
* - `key` must be a null-terminated UTF-8 string, containing LF-separated machines.
* - `value` must be a valid pointer to some valid and aligned pointer-sized memory.
*/
diff --git a/ios/MullvadVPNTests/MullvadREST/MullvadApi/RustProblemReportRequestTests.swift b/ios/MullvadVPNTests/MullvadREST/MullvadApi/RustProblemReportRequestTests.swift
index b4058fba85..aefcfea931 100644
--- a/ios/MullvadVPNTests/MullvadREST/MullvadApi/RustProblemReportRequestTests.swift
+++ b/ios/MullvadVPNTests/MullvadREST/MullvadApi/RustProblemReportRequestTests.swift
@@ -31,7 +31,7 @@ struct RustProblemReportRequestTests {
)
let rustRequest = RustProblemReportRequest(from: request)
let rustStruct = rustRequest.toRust()
- #expect(rustStruct.meta_data != nil, "Metadata should not be for \(metadata)")
+ #expect(rustStruct.metadata != nil, "Metadata should not be for \(metadata)")
}
@Test("Test invalid metadata insertion for SendProblemReport")
@@ -41,7 +41,7 @@ struct RustProblemReportRequestTests {
[0x7E]: [0x80], // Valid key , but invalid start byte in UTF-8
[0xE0, 0x80]: [0xC2, 0x80], // Malformed UTF-8 multibyte sequence for key and valid value
]
- let metadata = swift_problem_report_meta_data_new()
+ let metadata = swift_problem_report_metadata_new()
for (keyBytes, valueBytes) in invalidMetadata {
keyBytes.withUnsafeBytes { (keyPtr: UnsafeRawBufferPointer) in
valueBytes.withUnsafeBytes { (valuePtr: UnsafeRawBufferPointer) in
@@ -50,7 +50,7 @@ struct RustProblemReportRequestTests {
return
}
- let result = swift_problem_report_meta_data_add(
+ let result = swift_problem_report_metadata_add(
metadata,
keyBaseAddress,
valueBaseAddress