diff options
| author | mojganii <mojgan.jelodar@codic.se> | 2025-04-09 17:00:15 +0200 |
|---|---|---|
| committer | mojganii <mojgan.jelodar@codic.se> | 2025-04-15 15:38:45 +0200 |
| commit | 9eab3722f672e8073218c9ce81999945ef095794 (patch) | |
| tree | eace99e5a5e6206923714cfcef89698089309791 /ios/MullvadRustRuntime/include | |
| parent | d7dcd81cc2c9238cb21d5036ee3dc4baadd2d02b (diff) | |
| download | mullvadvpn-9eab3722f672e8073218c9ce81999945ef095794.tar.xz mullvadvpn-9eab3722f672e8073218c9ce81999945ef095794.zip | |
Improve sendProblemReport based on feedbacks
Diffstat (limited to 'ios/MullvadRustRuntime/include')
| -rw-r--r-- | ios/MullvadRustRuntime/include/mullvad_rust_runtime.h | 66 |
1 files changed, 46 insertions, 20 deletions
diff --git a/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h b/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h index 958144c802..bb87b1baa7 100644 --- a/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h +++ b/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h @@ -61,13 +61,10 @@ typedef struct ProblemReportMetadata { } ProblemReportMetadata; typedef struct SwiftProblemReportRequest { - const uint8_t *address; - uintptr_t address_len; - const uint8_t *message; - uintptr_t message_len; - const uint8_t *log; - uintptr_t log_len; - struct ProblemReportMetadata meta_data; + const char *address; + const char *message; + const char *log; + struct ProblemReportMetadata metadata; } SwiftProblemReportRequest; typedef struct ProxyHandle { @@ -241,6 +238,48 @@ extern void mullvad_api_completion_finish(struct SwiftMullvadApiResponse respons struct CompletionCookie completion_cookie); /** + * Send a problem report via the Mullvad API client. + * + * # 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. + * + * 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, + void *completion_cookie, + struct SwiftRetryStrategy retry_strategy, + struct SwiftProblemReportRequest request); + +struct ProblemReportMetadata swift_problem_report_metadata_new(void); + +/** + * Add key and value pair to the `ProblemReportMetadata` + * + * # Safety + * + * `self` must be a valid, exclusive pointer to `ProblemReportMetadata`, initialized + * - `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. + */ +bool swift_problem_report_metadata_add(struct ProblemReportMetadata map, + const char *key, + const char *value); + +void swift_problem_report_metadata_free(struct ProblemReportMetadata map); + +/** * Called by the Swift side to signal that the Rust `SwiftMullvadApiResponse` can be safely * dropped from memory. * @@ -274,19 +313,6 @@ struct SwiftRetryStrategy mullvad_api_retry_strategy_exponential(uintptr_t max_r uint32_t factor, uint64_t max_delay_sec); -struct SwiftCancelHandle mullvad_api_send_problem_report(struct SwiftApiContext api_context, - void *completion_cookie, - struct SwiftRetryStrategy retry_strategy, - struct SwiftProblemReportRequest request); - -struct ProblemReportMetadata swift_problem_report_meta_data_new(void); - -bool swift_problem_report_meta_data_add(struct ProblemReportMetadata map, - const char *key, - const char *value); - -void swift_problem_report_meta_data_free(struct ProblemReportMetadata map); - /** * Initializes a valid pointer to an instance of `EncryptedDnsProxyState`. * |
