diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2025-07-09 12:51:42 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2025-07-09 12:51:42 +0200 |
| commit | bef9cb8441e1369865ff345550ebb9c528dd3aca (patch) | |
| tree | fcac2cea9e6f7c6e270bedbdc5a81b0c0096f555 /mullvad-api/src | |
| parent | b21c24e98078145b19b6fc0eb75163e4b4364253 (diff) | |
| parent | 485d6b1b81ddf9a038dc93c4ed0f000d9aff107b (diff) | |
| download | mullvadvpn-bef9cb8441e1369865ff345550ebb9c528dd3aca.tar.xz mullvadvpn-bef9cb8441e1369865ff345550ebb9c528dd3aca.zip | |
Merge branch 'fix-rust-warnings-prepare-1.88'
Diffstat (limited to 'mullvad-api/src')
| -rw-r--r-- | mullvad-api/src/access_mode.rs | 4 | ||||
| -rw-r--r-- | mullvad-api/src/https_client_with_sni.rs | 6 | ||||
| -rw-r--r-- | mullvad-api/src/lib.rs | 7 | ||||
| -rw-r--r-- | mullvad-api/src/proxy.rs | 4 |
4 files changed, 9 insertions, 12 deletions
diff --git a/mullvad-api/src/access_mode.rs b/mullvad-api/src/access_mode.rs index ecd90b9d82..3cdb59c9c2 100644 --- a/mullvad-api/src/access_mode.rs +++ b/mullvad-api/src/access_mode.rs @@ -92,7 +92,7 @@ pub enum Error { #[error("Could not resolve access method {access_method:#?}")] Resolve { access_method: AccessMethod }, #[error("AccessModeSelector is not receiving any messages.")] - SendFailed(#[from] mpsc::TrySendError<Message>), + SendFailed(#[from] Box<mpsc::TrySendError<Message>>), #[error("AccessModeSelector is not receiving any messages.")] OneshotSendFailed, #[error("AccessModeSelector is not responding.")] @@ -135,7 +135,7 @@ pub struct AccessModeSelectorHandle { impl AccessModeSelectorHandle { async fn send_command<T>(&self, make_cmd: impl FnOnce(ResponseTx<T>) -> Message) -> Result<T> { let (tx, rx) = oneshot::channel(); - self.cmd_tx.unbounded_send(make_cmd(tx))?; + self.cmd_tx.unbounded_send(make_cmd(tx)).map_err(Box::new)?; rx.await.map_err(Error::NotRunning)? } diff --git a/mullvad-api/src/https_client_with_sni.rs b/mullvad-api/src/https_client_with_sni.rs index f86c538a67..d5e595e373 100644 --- a/mullvad-api/src/https_client_with_sni.rs +++ b/mullvad-api/src/https_client_with_sni.rs @@ -148,9 +148,7 @@ impl InnerConnectionMode { .await } } - .map_err(|error| { - io::Error::new(io::ErrorKind::Other, format!("SOCKS error: {error}")) - }) + .map_err(|error| io::Error::other(format!("SOCKS error: {error}"))) }; Self::connect_proxied( first_hop, @@ -415,7 +413,7 @@ impl HttpsConnectorWithSni { let addrs = dns_resolver.resolve(hostname.to_owned()).await?; let addr = addrs .first() - .ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Empty DNS response"))?; + .ok_or_else(|| io::Error::other("Empty DNS response"))?; let port = match (addr.port(), port) { (_, Some(port)) => port, (0, None) => DEFAULT_PORT, diff --git a/mullvad-api/src/lib.rs b/mullvad-api/src/lib.rs index 4ba91a28c6..4acbff321c 100644 --- a/mullvad-api/src/lib.rs +++ b/mullvad-api/src/lib.rs @@ -139,12 +139,11 @@ impl ApiEndpoint { api_addr = env::API_ADDR_VAR, api_host = env::API_HOST_VAR ); - api.address = format!("{}:{}", host, API_PORT_DEFAULT) + api.address = format!("{host}:{API_PORT_DEFAULT}") .to_socket_addrs() .unwrap_or_else(|_| { panic!( - "Unable to resolve API IP address from host {host}:{port}", - port = API_PORT_DEFAULT, + "Unable to resolve API IP address from host {host}:{API_PORT_DEFAULT}" ) }) .next(); @@ -714,7 +713,7 @@ impl ProblemReportProxy { message: &str, log: &str, metadata: &BTreeMap<String, String>, - ) -> impl Future<Output = Result<(), rest::Error>> { + ) -> impl Future<Output = Result<(), rest::Error>> + use<> { #[derive(serde::Serialize)] struct ProblemReport { address: String, diff --git a/mullvad-api/src/proxy.rs b/mullvad-api/src/proxy.rs index 106449bb30..2a4406d7f0 100644 --- a/mullvad-api/src/proxy.rs +++ b/mullvad-api/src/proxy.rs @@ -129,7 +129,7 @@ impl ApiConnectionMode { "Failed to deserialize \"{CURRENT_CONFIG_FILENAME}\"" )) ); - io::Error::new(io::ErrorKind::Other, "deserialization failed") + io::Error::other("deserialization failed") }), Err(error) => { if error.kind() == io::ErrorKind::NotFound { @@ -145,7 +145,7 @@ impl ApiConnectionMode { pub async fn save(&self, cache_dir: &Path) -> io::Result<()> { let mut file = mullvad_fs::AtomicFile::new(cache_dir.join(CURRENT_CONFIG_FILENAME)).await?; let json = serde_json::to_string_pretty(self) - .map_err(|_| io::Error::new(io::ErrorKind::Other, "serialization failed"))?; + .map_err(|_| io::Error::other("serialization failed"))?; file.write_all(json.as_bytes()).await?; file.write_all(b"\n").await?; file.finalize().await |
