Remove unnecessary casts statements
This commit is contained in:
parent
e19578a7ea
commit
e3ccff9b83
@ -257,7 +257,7 @@ extension REST {
|
||||
request: LegacyStorekitRequest,
|
||||
retryStrategy: REST.RetryStrategy,
|
||||
completionHandler: @escaping ProxyCompletionHandler<REST.CreateApplePaymentResponse>
|
||||
) -> any MullvadTypes.Cancellable {
|
||||
) -> any Cancellable {
|
||||
AnyCancellable()
|
||||
}
|
||||
|
||||
@ -266,25 +266,25 @@ extension REST {
|
||||
accountNumber: String,
|
||||
retryStrategy: REST.RetryStrategy,
|
||||
completionHandler: @escaping ProxyCompletionHandler<String>
|
||||
) -> any MullvadTypes.Cancellable {
|
||||
) -> any Cancellable {
|
||||
AnyCancellable()
|
||||
}
|
||||
|
||||
/// Not implemented. Use `MullvadAPIProxy` instead.
|
||||
public func checkStorekitPayment(
|
||||
accountNumber: String,
|
||||
transaction: MullvadTypes.StorekitTransaction,
|
||||
transaction: StorekitTransaction,
|
||||
retryStrategy: REST.RetryStrategy,
|
||||
completionHandler: @escaping ProxyCompletionHandler<Void>
|
||||
) -> any MullvadTypes.Cancellable {
|
||||
) -> any Cancellable {
|
||||
AnyCancellable()
|
||||
}
|
||||
|
||||
public func checkApiAvailability(
|
||||
retryStrategy: REST.RetryStrategy,
|
||||
accessMethod: MullvadTypes.PersistentAccessMethod,
|
||||
accessMethod: PersistentAccessMethod,
|
||||
completion: @escaping ProxyCompletionHandler<Bool>
|
||||
) -> any MullvadTypes.Cancellable {
|
||||
) -> any Cancellable {
|
||||
AnyCancellable()
|
||||
}
|
||||
}
|
||||
|
@ -89,10 +89,10 @@ typedef struct LateStringDeallocator {
|
||||
typedef struct SwiftMullvadApiResponse {
|
||||
uint8_t *body;
|
||||
uintptr_t body_size;
|
||||
uint8_t *etag;
|
||||
char *etag;
|
||||
uint16_t status_code;
|
||||
uint8_t *error_description;
|
||||
uint8_t *server_response_code;
|
||||
char *error_description;
|
||||
char *server_response_code;
|
||||
bool success;
|
||||
} SwiftMullvadApiResponse;
|
||||
|
||||
|
@ -102,31 +102,27 @@ pub unsafe extern "C" fn mullvad_ios_api_addrs_available(
|
||||
.resolve(access_method_setting.clone())
|
||||
.await
|
||||
{
|
||||
Ok(maybe_resolved_connection_mode) => match maybe_resolved_connection_mode {
|
||||
Some(resolved_connection_mode) => {
|
||||
let oneshot_client = api_context.api_client.mullvad_rest_handle(
|
||||
resolved_connection_mode.connection_mode.into_provider(),
|
||||
);
|
||||
Ok(Some(resolved_connection_mode)) => {
|
||||
let oneshot_client = api_context
|
||||
.api_client
|
||||
.mullvad_rest_handle(resolved_connection_mode.connection_mode.into_provider());
|
||||
|
||||
match mullvad_ios_api_addrs_available_inner(oneshot_client, retry_strategy)
|
||||
.await
|
||||
{
|
||||
Ok(_) => completion.finish(SwiftMullvadApiResponse::ok()),
|
||||
Err(err) => {
|
||||
log::error!("{err:?}");
|
||||
completion.finish(SwiftMullvadApiResponse::rest_error(err));
|
||||
}
|
||||
match mullvad_ios_api_addrs_available_inner(oneshot_client, retry_strategy).await {
|
||||
Ok(_) => completion.finish(SwiftMullvadApiResponse::ok()),
|
||||
Err(err) => {
|
||||
log::error!("{err:?}");
|
||||
completion.finish(SwiftMullvadApiResponse::rest_error(err));
|
||||
}
|
||||
}
|
||||
None => {
|
||||
log::error!("Invalid access method configuration, {access_method_setting:?}");
|
||||
completion.finish(SwiftMullvadApiResponse::access_method_error(
|
||||
mullvad_api::access_mode::Error::Resolve {
|
||||
access_method: access_method_setting.access_method,
|
||||
},
|
||||
));
|
||||
}
|
||||
},
|
||||
}
|
||||
Ok(None) => {
|
||||
log::error!("Invalid access method configuration, {access_method_setting:?}");
|
||||
completion.finish(SwiftMullvadApiResponse::access_method_error(
|
||||
mullvad_api::access_mode::Error::Resolve {
|
||||
access_method: access_method_setting.access_method,
|
||||
},
|
||||
));
|
||||
}
|
||||
Err(err) => {
|
||||
log::error!("{err:?}");
|
||||
completion.finish(SwiftMullvadApiResponse::access_method_error(err));
|
||||
|
@ -1,5 +1,5 @@
|
||||
use std::{
|
||||
ffi::CString,
|
||||
ffi::{c_char, CString},
|
||||
ptr::{self, null_mut},
|
||||
};
|
||||
|
||||
@ -12,10 +12,10 @@ use mullvad_api::{
|
||||
pub struct SwiftMullvadApiResponse {
|
||||
body: *mut u8,
|
||||
body_size: usize,
|
||||
etag: *mut u8,
|
||||
etag: *mut c_char,
|
||||
status_code: u16,
|
||||
error_description: *mut u8,
|
||||
server_response_code: *mut u8,
|
||||
error_description: *mut c_char,
|
||||
server_response_code: *mut c_char,
|
||||
success: bool,
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ impl SwiftMullvadApiResponse {
|
||||
Some(etag) => {
|
||||
let header_value =
|
||||
CString::new(etag).map_err(|_| rest::Error::InvalidHeaderError)?;
|
||||
header_value.into_raw().cast()
|
||||
header_value.into_raw()
|
||||
}
|
||||
None => ptr::null_mut(),
|
||||
};
|
||||
@ -64,7 +64,7 @@ impl SwiftMullvadApiResponse {
|
||||
pub fn access_method_error(err: mullvad_api::access_mode::Error) -> Self {
|
||||
let to_cstr_pointer = |str| {
|
||||
CString::new(str)
|
||||
.map(|cstr| cstr.into_raw().cast())
|
||||
.map(|cstr| cstr.into_raw())
|
||||
.unwrap_or(null_mut())
|
||||
};
|
||||
let error_description = to_cstr_pointer(err.to_string());
|
||||
@ -87,7 +87,7 @@ impl SwiftMullvadApiResponse {
|
||||
|
||||
let to_cstr_pointer = |str| {
|
||||
CString::new(str)
|
||||
.map(|cstr| cstr.into_raw().cast())
|
||||
.map(|cstr| cstr.into_raw())
|
||||
.unwrap_or(null_mut())
|
||||
};
|
||||
|
||||
@ -113,7 +113,7 @@ impl SwiftMullvadApiResponse {
|
||||
pub fn cancelled() -> Self {
|
||||
Self {
|
||||
success: false,
|
||||
error_description: c"Request was cancelled".to_owned().into_raw().cast(),
|
||||
error_description: c"Request was cancelled".to_owned().into_raw(),
|
||||
body: null_mut(),
|
||||
body_size: 0,
|
||||
etag: null_mut(),
|
||||
@ -125,7 +125,7 @@ impl SwiftMullvadApiResponse {
|
||||
pub fn no_tokio_runtime() -> Self {
|
||||
Self {
|
||||
success: false,
|
||||
error_description: c"Failed to get Tokio runtime".to_owned().into_raw().cast(),
|
||||
error_description: c"Failed to get Tokio runtime".to_owned().into_raw(),
|
||||
body: null_mut(),
|
||||
body_size: 0,
|
||||
etag: null_mut(),
|
||||
@ -149,14 +149,14 @@ pub unsafe extern "C" fn mullvad_response_drop(response: SwiftMullvadApiResponse
|
||||
}
|
||||
|
||||
if !response.etag.is_null() {
|
||||
let _ = CString::from_raw(response.etag.cast());
|
||||
let _ = CString::from_raw(response.etag);
|
||||
}
|
||||
|
||||
if !response.error_description.is_null() {
|
||||
let _ = CString::from_raw(response.error_description.cast());
|
||||
let _ = CString::from_raw(response.error_description);
|
||||
}
|
||||
|
||||
if !response.server_response_code.is_null() {
|
||||
let _ = CString::from_raw(response.server_response_code.cast());
|
||||
let _ = CString::from_raw(response.server_response_code);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user