mirror of
https://github.com/YGGverse/aquatic-crawler.git
synced 2026-04-01 17:45:39 +00:00
implement some 0.2.0 features
This commit is contained in:
parent
18116491cb
commit
10c2d7e855
11 changed files with 319 additions and 157 deletions
20
src/trackers.rs
Normal file
20
src/trackers.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
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 clone(&self) -> HashSet<Url> {
|
||||
self.0.clone()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue