use std::collections::HashMap;
#[cfg(not(target_arch = "wasm32"))]
use url::Url;
#[cfg(not(target_arch = "wasm32"))]
#[derive(Debug, Clone)]
pub struct CrawlRequest {
pub url: String,
pub headers: HashMap<String, String>,
pub tier: Option<&'static str>,
}
#[cfg(not(target_arch = "wasm32"))]
impl CrawlRequest {
pub fn new(url: impl Into<String>) -> Self {
Self {
url: url.into(),
headers: HashMap::new(),
tier: None,
}
}
pub fn domain(&self) -> Option<String> {
Url::parse(&self.url)
.ok()
.and_then(|u| u.host_str().map(|s| s.to_owned()))
}
}
#[derive(Debug, Clone)]
pub struct CrawlResponse {
pub status: u16,
pub content_type: String,
pub body: String,
pub body_bytes: Vec<u8>,
pub headers: HashMap<String, Vec<String>>,
}