summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSebastian Holmin <sebastian.holmin@mullvad.net>2024-04-02 12:24:10 +0200
committerMarkus Pettersson <markus.pettersson@mullvad.net>2024-04-04 16:48:37 +0200
commitc0b0304be43f994dc661d18696085dbd415afb24 (patch)
tree44d8037ea9f552227dfce5a5e2358bc580a8cec5
parent1fb587dc052daef7f84a6732774b42d2ad935f2c (diff)
downloadmullvadvpn-c0b0304be43f994dc661d18696085dbd415afb24.tar.xz
mullvadvpn-c0b0304be43f994dc661d18696085dbd415afb24.zip
Remove `Set` trait
-rw-r--r--mullvad-types/src/constraints/mod.rs5
-rw-r--r--mullvad-types/src/relay_constraints.rs47
2 files changed, 2 insertions, 50 deletions
diff --git a/mullvad-types/src/constraints/mod.rs b/mullvad-types/src/constraints/mod.rs
index 8ee6e93195..756066c447 100644
--- a/mullvad-types/src/constraints/mod.rs
+++ b/mullvad-types/src/constraints/mod.rs
@@ -5,10 +5,7 @@ mod constraint;
// Re-export bits & pieces from `constraints.rs` as needed
pub use constraint::Constraint;
-/// A limited variant of Sets.
-pub trait Set<T> {
- fn is_subset(&self, other: &T) -> bool;
-}
+use crate::relay_constraints;
pub trait Match<T> {
fn matches(&self, other: &T) -> bool;
diff --git a/mullvad-types/src/relay_constraints.rs b/mullvad-types/src/relay_constraints.rs
index dc6d0608e5..9b6b640cf5 100644
--- a/mullvad-types/src/relay_constraints.rs
+++ b/mullvad-types/src/relay_constraints.rs
@@ -2,7 +2,7 @@
//! updated as well.
use crate::{
- constraints::{Constraint, Match, Set},
+ constraints::{Constraint, Match},
custom_list::{CustomListsSettings, Id},
location::{CityCode, CountryCode, Hostname},
relay_list::Relay,
@@ -294,51 +294,6 @@ impl Match<Relay> for GeographicLocationConstraint {
}
}
-impl Set<GeographicLocationConstraint> for GeographicLocationConstraint {
- /// Returns whether `self` is equal to or a subset of `other`.
- fn is_subset(&self, other: &Self) -> bool {
- match self {
- GeographicLocationConstraint::Country(_) => self == other,
- GeographicLocationConstraint::City(ref country, ref _city) => match other {
- GeographicLocationConstraint::Country(ref other_country) => {
- country == other_country
- }
- GeographicLocationConstraint::City(..) => self == other,
- _ => false,
- },
- GeographicLocationConstraint::Hostname(ref country, ref city, ref _hostname) => {
- match other {
- GeographicLocationConstraint::Country(ref other_country) => {
- country == other_country
- }
- GeographicLocationConstraint::City(ref other_country, ref other_city) => {
- country == other_country && city == other_city
- }
- GeographicLocationConstraint::Hostname(..) => self == other,
- }
- }
- }
- }
-}
-
-impl Set<Constraint<Vec<GeographicLocationConstraint>>>
- for Constraint<Vec<GeographicLocationConstraint>>
-{
- fn is_subset(&self, other: &Self) -> bool {
- match self {
- Constraint::Any => other.is_any(),
- Constraint::Only(locations) => match other {
- Constraint::Any => true,
- Constraint::Only(other_locations) => locations.iter().all(|location| {
- other_locations
- .iter()
- .any(|other_location| location.is_subset(other_location))
- }),
- },
- }
- }
-}
-
/// Limits the set of servers to choose based on ownership.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[cfg_attr(target_os = "android", derive(IntoJava, FromJava))]