diff options
| author | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2025-04-23 10:47:09 +0200 |
|---|---|---|
| committer | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2025-04-23 10:47:09 +0200 |
| commit | 78412f8c1e7a563fe2604ad6edea4b4fda1fc0ab (patch) | |
| tree | 7a882a2c99db709a98a261298a014d67ea353a37 | |
| parent | 735e9cd7cabf44e9a220bc719693cf38134c3897 (diff) | |
| parent | af38d33c942d1fda43a6d2fbf7efe4116674da3e (diff) | |
| download | mullvadvpn-78412f8c1e7a563fe2604ad6edea4b4fda1fc0ab.tar.xz mullvadvpn-78412f8c1e7a563fe2604ad6edea4b4fda1fc0ab.zip | |
Merge branch 'remove-async-trait-macro'
| -rw-r--r-- | Cargo.lock | 1 | ||||
| -rw-r--r-- | installer-downloader/src/ui_downloader.rs | 1 | ||||
| -rw-r--r-- | installer-downloader/tests/mock.rs | 2 | ||||
| -rw-r--r-- | mullvad-update/Cargo.toml | 3 | ||||
| -rw-r--r-- | mullvad-update/src/client/api.rs | 7 | ||||
| -rw-r--r-- | mullvad-update/src/client/app.rs | 10 | ||||
| -rw-r--r-- | test/Cargo.lock | 1 |
7 files changed, 9 insertions, 16 deletions
diff --git a/Cargo.lock b/Cargo.lock index 6d9abdc891..88765eddbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3011,7 +3011,6 @@ version = "0.0.0" dependencies = [ "anyhow", "async-tempfile", - "async-trait", "chrono", "clap", "ed25519-dalek", diff --git a/installer-downloader/src/ui_downloader.rs b/installer-downloader/src/ui_downloader.rs index c69b1f9599..a31e9e75eb 100644 --- a/installer-downloader/src/ui_downloader.rs +++ b/installer-downloader/src/ui_downloader.rs @@ -33,7 +33,6 @@ impl<Delegate: AppDelegate, Downloader: AppDownloader + Send + 'static> } } -#[async_trait::async_trait] impl<Delegate: AppDelegate, Downloader: AppDownloader + Send + 'static> AppDownloader for UiAppDownloader<Delegate, Downloader> { diff --git a/installer-downloader/tests/mock.rs b/installer-downloader/tests/mock.rs index 51a20f347d..a193f2d9a7 100644 --- a/installer-downloader/tests/mock.rs +++ b/installer-downloader/tests/mock.rs @@ -37,7 +37,6 @@ pub const FAKE_ENVIRONMENT: Environment = Environment { architecture: Architecture::X86, }; -#[async_trait::async_trait] impl VersionInfoProvider for FakeVersionInfoProvider { async fn get_version_info(&self, _params: VersionParameters) -> anyhow::Result<VersionInfo> { if self.fail_fetching.load(std::sync::atomic::Ordering::SeqCst) { @@ -88,7 +87,6 @@ pub struct FakeAppDownloader< params: UiAppDownloaderParameters<FakeAppDelegate>, } -#[async_trait::async_trait] impl<const EXE_SUCCEED: bool, const VERIFY_SUCCEED: bool, const LAUNCH_SUCCEED: bool> AppDownloader for FakeAppDownloader<EXE_SUCCEED, VERIFY_SUCCEED, LAUNCH_SUCCEED> { diff --git a/mullvad-update/Cargo.toml b/mullvad-update/Cargo.toml index 4bd9a5c74b..69f8005e8f 100644 --- a/mullvad-update/Cargo.toml +++ b/mullvad-update/Cargo.toml @@ -13,7 +13,7 @@ workspace = true [features] default = [] sign = ["rand", "clap"] -client = ["async-trait", "reqwest", "sha2", "tokio", "thiserror"] +client = ["reqwest", "sha2", "tokio", "thiserror"] [dependencies] anyhow = { workspace = true } @@ -25,7 +25,6 @@ serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } zeroize = { version = "1.8", features = ["zeroize_derive"] } -async-trait = { version = "0.1", optional = true } reqwest = { version = "0.12.9", default-features = false, features = ["rustls-tls"], optional = true } sha2 = { version = "0.10", optional = true } tokio = { workspace = true, features = ["rt-multi-thread", "fs", "process", "macros"], optional = true } diff --git a/mullvad-update/src/client/api.rs b/mullvad-update/src/client/api.rs index c4953177b3..d4806325e5 100644 --- a/mullvad-update/src/client/api.rs +++ b/mullvad-update/src/client/api.rs @@ -48,10 +48,12 @@ impl MetaRepositoryPlatform { } /// See [module-level](self) docs. -#[async_trait::async_trait] pub trait VersionInfoProvider { /// Return info about the stable version - async fn get_version_info(&self, params: VersionParameters) -> anyhow::Result<VersionInfo>; + fn get_version_info( + &self, + params: VersionParameters, + ) -> impl std::future::Future<Output = anyhow::Result<VersionInfo>> + Send; } /// Obtain version data using a GET request @@ -62,7 +64,6 @@ pub struct HttpVersionInfoProvider { pinned_certificate: Option<reqwest::Certificate>, } -#[async_trait::async_trait] impl VersionInfoProvider for HttpVersionInfoProvider { async fn get_version_info(&self, params: VersionParameters) -> anyhow::Result<VersionInfo> { let response = self.get_versions(params.lowest_metadata_version).await?; diff --git a/mullvad-update/src/client/app.rs b/mullvad-update/src/client/app.rs index 6b894dd201..90dc4314e2 100644 --- a/mullvad-update/src/client/app.rs +++ b/mullvad-update/src/client/app.rs @@ -2,7 +2,7 @@ //! This module implements the flow of downloading and verifying the app. -use std::{ffi::OsString, path::PathBuf, time::Duration}; +use std::{ffi::OsString, future::Future, path::PathBuf, time::Duration}; use tokio::{process::Command, time::timeout}; @@ -39,16 +39,15 @@ pub struct AppDownloaderParameters<AppProgress> { } /// See the [module-level documentation](self). -#[async_trait::async_trait] pub trait AppDownloader: Send { /// Download the app binary. - async fn download_executable(&mut self) -> Result<(), DownloadError>; + fn download_executable(&mut self) -> impl Future<Output = Result<(), DownloadError>> + Send; /// Verify the app signature. - async fn verify(&mut self) -> Result<(), DownloadError>; + fn verify(&mut self) -> impl Future<Output = Result<(), DownloadError>> + Send; /// Execute installer. - async fn install(&mut self) -> Result<(), DownloadError>; + fn install(&mut self) -> impl Future<Output = Result<(), DownloadError>> + Send; } /// How long to wait for the installer to exit before returning @@ -80,7 +79,6 @@ impl<AppProgress: ProgressUpdater> From<AppDownloaderParameters<AppProgress>> } } -#[async_trait::async_trait] impl<AppProgress: ProgressUpdater> AppDownloader for HttpAppDownloader<AppProgress> { async fn download_executable(&mut self) -> Result<(), DownloadError> { let bin_path = self.bin_path(); diff --git a/test/Cargo.lock b/test/Cargo.lock index 7987d395a3..31777ef776 100644 --- a/test/Cargo.lock +++ b/test/Cargo.lock @@ -2195,7 +2195,6 @@ name = "mullvad-update" version = "0.0.0" dependencies = [ "anyhow", - "async-trait", "chrono", "ed25519-dalek", "hex", |
