Skip to content

Commit 932e66e

Browse files
committed
feat: [#870] add privacy methods to the TrackerMode
The tracker mode can be: - Public (Non-whitelisted) - Listed (Whitelisted) - Private (Non-whitelisted) - PrivateListed (Whitelisted) They should have been two different flags (in my opinion): - Visibility: public or private - Whitelisted: true or false So we would have the same four convinations: - Not whitelisted: - Public - Private - Whitelisted - Public - Private That's a pending refactor. For this commits, the goal is just to align this enum with what we added to the Index so we can use this enum in the Index via the primmitives crate.
1 parent d4eaea9 commit 932e66e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/primitives/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,21 @@ pub enum TrackerMode {
8585
#[serde(rename = "private_listed")]
8686
PrivateListed,
8787
}
88+
89+
impl Default for TrackerMode {
90+
fn default() -> Self {
91+
Self::Public
92+
}
93+
}
94+
95+
impl TrackerMode {
96+
#[must_use]
97+
pub fn is_open(&self) -> bool {
98+
matches!(self, TrackerMode::Public | TrackerMode::Listed)
99+
}
100+
101+
#[must_use]
102+
pub fn is_close(&self) -> bool {
103+
!self.is_open()
104+
}
105+
}

0 commit comments

Comments
 (0)