diff --git a/mullvad-api/src/availability.rs b/mullvad-api/src/availability.rs index ab3dc406f7e4..976b03820245 100644 --- a/mullvad-api/src/availability.rs +++ b/mullvad-api/src/availability.rs @@ -16,14 +16,6 @@ pub enum Error { Interrupted(#[from] broadcast::error::RecvError), } -#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)] -pub struct State { - suspended: bool, - pause_background: bool, - offline: bool, - inactive: bool, -} - #[derive(Clone, Debug)] pub struct ApiAvailability(Arc>); @@ -34,6 +26,14 @@ struct ApiAvailabilityState { inactivity_timer: Option>, } +#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)] +pub struct State { + suspended: bool, + pause_background: bool, + offline: bool, + inactive: bool, +} + impl State { pub const fn is_suspended(&self) -> bool { self.suspended @@ -179,6 +179,12 @@ impl ApiAvailability { } } +impl Default for ApiAvailability { + fn default() -> Self { + ApiAvailability::new(State::default()) + } +} + impl ApiAvailabilityState { fn suspend(&mut self) { if !self.state.suspended { diff --git a/mullvad-api/src/lib.rs b/mullvad-api/src/lib.rs index 8add11d30a3f..ebc1401a5f84 100644 --- a/mullvad-api/src/lib.rs +++ b/mullvad-api/src/lib.rs @@ -340,7 +340,7 @@ impl Runtime { Runtime { handle, address_cache: AddressCache::with_static_addr(address), - api_availability: ApiAvailability::new(availability::State::default()), + api_availability: ApiAvailability::default(), } } @@ -351,7 +351,7 @@ impl Runtime { Ok(Runtime { handle, address_cache: AddressCache::new(None)?, - api_availability: ApiAvailability::new(availability::State::default()), + api_availability: ApiAvailability::default(), #[cfg(target_os = "android")] socket_bypass_tx, }) @@ -396,10 +396,12 @@ impl Runtime { } }; + let api_availability = ApiAvailability::default(); + Ok(Runtime { handle, address_cache, - api_availability: ApiAvailability::new(availability::State::default()), + api_availability, #[cfg(target_os = "android")] socket_bypass_tx, })