diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2019-10-07 14:53:10 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2019-10-07 16:24:41 +0200 |
| commit | 4c8ff3f8ec7baf674b95536a94e18e79440b428f (patch) | |
| tree | 00ed94738e56b11e77023e5d95ddc54a1a5b7116 | |
| parent | 28d3b6ec74dfb6fd063f5ffb572a2c48b944dc86 (diff) | |
| download | mullvadvpn-4c8ff3f8ec7baf674b95536a94e18e79440b428f.tar.xz mullvadvpn-4c8ff3f8ec7baf674b95536a94e18e79440b428f.zip | |
Move error type to top of module
| -rw-r--r-- | mullvad-daemon/src/version_check.rs | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/mullvad-daemon/src/version_check.rs b/mullvad-daemon/src/version_check.rs index 5b318a881e..65530ae20f 100644 --- a/mullvad-daemon/src/version_check.rs +++ b/mullvad-daemon/src/version_check.rs @@ -32,6 +32,32 @@ const PLATFORM: &str = "windows"; #[cfg(target_os = "android")] const PLATFORM: &str = "android"; + +#[derive(err_derive::Error, Debug)] +pub enum Error { + #[error(display = "Failed to open app version cache file for reading")] + ReadCachedRelays(#[error(cause)] io::Error), + + #[error(display = "Failed to open app version cache file for writing")] + WriteRelayCache(#[error(cause)] io::Error), + + #[error(display = "Failure in serialization of the version info")] + Serialize(#[error(cause)] serde_json::Error), + + #[error(display = "Timed out when trying to check the latest app version")] + DownloadTimeout, + + #[error(display = "Failed to check the latest app version")] + Download(#[error(cause)] mullvad_rpc::Error), +} + +impl<F> From<TimeoutError<F>> for Error { + fn from(_: TimeoutError<F>) -> Error { + Error::DownloadTimeout + } +} + + pub struct VersionUpdater<F: Fn(&AppVersionInfo) + Send + 'static> { version_proxy: AppVersionProxy<HttpHandle>, cache_path: PathBuf, @@ -149,27 +175,3 @@ pub fn load_cache(cache_dir: &Path) -> Result<AppVersionInfo, Error> { let file = File::open(path).map_err(Error::ReadCachedRelays)?; serde_json::from_reader(io::BufReader::new(file)).map_err(Error::Serialize) } - -#[derive(err_derive::Error, Debug)] -pub enum Error { - #[error(display = "Failed to open app version cache file for reading")] - ReadCachedRelays(#[error(cause)] io::Error), - - #[error(display = "Failed to open app version cache file for writing")] - WriteRelayCache(#[error(cause)] io::Error), - - #[error(display = "Failure in serialization of the version info")] - Serialize(#[error(cause)] serde_json::Error), - - #[error(display = "Timed out when trying to check the latest app version")] - DownloadTimeout, - - #[error(display = "Failed to check the latest app version")] - Download(#[error(cause)] mullvad_rpc::Error), -} - -impl<F> From<TimeoutError<F>> for Error { - fn from(_: TimeoutError<F>) -> Error { - Error::DownloadTimeout - } -} |
