diff options
| author | Markus Pettersson <markus.pettersson@mullvad.net> | 2025-07-15 13:09:41 +0200 |
|---|---|---|
| committer | Markus Pettersson <markus.pettersson@mullvad.net> | 2025-07-15 14:56:58 +0200 |
| commit | ebe328d1724a63c6d93df2155195ba7c5558fde2 (patch) | |
| tree | 78a6f14dc59eedea90f7065989ccf04164378dc5 /mullvad-api/src/rest.rs | |
| parent | de3b988970d47625cffb4497d4d425fa3a6d0a4b (diff) | |
| download | mullvadvpn-ebe328d1724a63c6d93df2155195ba7c5558fde2.tar.xz mullvadvpn-ebe328d1724a63c6d93df2155195ba7c5558fde2.zip | |
Fix `collapsible_if` clippy lint
Diffstat (limited to 'mullvad-api/src/rest.rs')
| -rw-r--r-- | mullvad-api/src/rest.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/mullvad-api/src/rest.rs b/mullvad-api/src/rest.rs index 5e7d13047e..3854f66ef4 100644 --- a/mullvad-api/src/rest.rs +++ b/mullvad-api/src/rest.rs @@ -101,11 +101,12 @@ impl Error { pub fn is_offline(&self) -> bool { match self { Error::LegacyHyperError(error) if error.is_connect() => { - if let Some(cause) = error.source() { - if let Some(err) = cause.downcast_ref::<std::io::Error>() { - return err.raw_os_error() == Some(libc::ENETUNREACH); - } + if let Some(cause) = error.source() + && let Some(err) = cause.downcast_ref::<std::io::Error>() + { + return err.raw_os_error() == Some(libc::ENETUNREACH); } + false } // TODO: Currently, we use the legacy hyper client for all REST requests. If this @@ -252,14 +253,14 @@ impl<T: ConnectionModeProvider + 'static> RequestService<T> { let response = request_future.await.map_err(|error| error.map_aborted()); // Switch API endpoint if the request failed due to a network error - if let Err(err) = &response { - if err.is_network_error() && !api_availability.is_offline() { - log::error!("{}", err.display_chain_with_msg("HTTP request failed")); - if let Some(tx) = tx { - let _ = tx.unbounded_send(RequestCommand::NextApiConfig( - connection_mode_generation, - )); - } + if let Err(err) = &response + && err.is_network_error() + && !api_availability.is_offline() + { + log::error!("{}", err.display_chain_with_msg("HTTP request failed")); + if let Some(tx) = tx { + let _ = tx + .unbounded_send(RequestCommand::NextApiConfig(connection_mode_generation)); } } |
