Skip to content

Commit

Permalink
feat: [#870] add privacy methods to the TrackerMode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
josecelano committed May 21, 2024
1 parent d4eaea9 commit 932e66e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,21 @@ pub enum TrackerMode {
#[serde(rename = "private_listed")]
PrivateListed,
}

impl Default for TrackerMode {
fn default() -> Self {
Self::Public
}
}

impl TrackerMode {
#[must_use]
pub fn is_open(&self) -> bool {
matches!(self, TrackerMode::Public | TrackerMode::Listed)
}

#[must_use]
pub fn is_close(&self) -> bool {
!self.is_open()
}
}

0 comments on commit 932e66e

Please sign in to comment.