mirror of
https://github.com/YGGverse/aquatic-crawler.git
synced 2026-04-01 01:25:36 +00:00
20 lines
492 B
Rust
20 lines
492 B
Rust
use std::{collections::HashSet, str::FromStr};
|
|
use url::Url;
|
|
|
|
pub struct Trackers(HashSet<Url>);
|
|
|
|
impl Trackers {
|
|
pub fn init(trackers: &Vec<String>) -> anyhow::Result<Self> {
|
|
let mut t = HashSet::with_capacity(trackers.len());
|
|
for tracker in trackers {
|
|
t.insert(Url::from_str(tracker)?);
|
|
}
|
|
Ok(Self(t))
|
|
}
|
|
pub fn is_empty(&self) -> bool {
|
|
self.0.is_empty()
|
|
}
|
|
pub fn list(&self) -> &HashSet<Url> {
|
|
&self.0
|
|
}
|
|
}
|