use async_trait::async_trait; use url::Url; pub type Error = Box; #[async_trait] pub trait Page: Send + Sync { async fn process_request( &self, ) -> Result<(Vec>, Vec>), Error>; fn get_url<'a>(&'a self) -> &'a String; fn get_group_mode(&self) -> GroupMode { return GroupMode::Domain; } } #[async_trait] pub trait PageResult: Send + Sync { async fn save_results(&self) -> Result<(), Error>; } pub enum GroupMode { Endpoint, Host, Domain, UniqueID(u64), } impl GroupMode { pub fn get_url(&self, url: &str) -> Result { match Url::parse(url) { Ok(url) => match self { GroupMode::Endpoint => Ok(format!("{}/{}", url.host_str().unwrap(), url.path())), GroupMode::Host => Ok(url.host_str().unwrap().to_string()), GroupMode::Domain => Ok(url.domain().unwrap().to_string()), GroupMode::UniqueID(id) => Ok(id.to_string()), }, Err(err) => Err(err), } } }