style: cargo fmt

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Valerio 2026-04-01 18:25:40 +02:00
parent 1a5d3d8aaf
commit 124352e0b4
2 changed files with 33 additions and 13 deletions

View file

@ -93,15 +93,33 @@ impl Response {
let status = resp.status().as_u16();
let url = resp.uri().to_string();
let headers = resp.headers().clone();
let body = resp.bytes().await.map_err(|e| FetchError::BodyDecode(e.to_string()))?;
Ok(Self { status, url, headers, body })
let body = resp
.bytes()
.await
.map_err(|e| FetchError::BodyDecode(e.to_string()))?;
Ok(Self {
status,
url,
headers,
body,
})
}
fn status(&self) -> u16 { self.status }
fn url(&self) -> &str { &self.url }
fn headers(&self) -> &http::HeaderMap { &self.headers }
fn body(&self) -> &[u8] { &self.body }
fn is_success(&self) -> bool { (200..300).contains(&self.status) }
fn status(&self) -> u16 {
self.status
}
fn url(&self) -> &str {
&self.url
}
fn headers(&self) -> &http::HeaderMap {
&self.headers
}
fn body(&self) -> &[u8] {
&self.body
}
fn is_success(&self) -> bool {
(200..300).contains(&self.status)
}
fn text(&self) -> std::borrow::Cow<'_, str> {
String::from_utf8_lossy(&self.body)
@ -147,7 +165,12 @@ impl FetchClient {
let clients = variants
.into_iter()
.map(|v| {
crate::tls::build_client(v, config.timeout, &config.headers, config.proxy.as_deref())
crate::tls::build_client(
v,
config.timeout,
&config.headers,
config.proxy.as_deref(),
)
})
.collect::<Result<Vec<_>, _>>()?;
@ -454,10 +477,7 @@ fn collect_variants(profile: &BrowserProfile) -> Vec<BrowserVariant> {
}
/// Convert a buffered Response into a FetchResult.
fn response_to_result(
response: Response,
start: Instant,
) -> Result<FetchResult, FetchError> {
fn response_to_result(response: Response, start: Instant) -> Result<FetchResult, FetchError> {
let status = response.status();
let final_url = response.url().to_string();
let headers = response.headers().clone();

View file

@ -16,7 +16,7 @@ pub use browser::BrowserProfile;
pub use client::{BatchExtractResult, BatchResult, FetchClient, FetchConfig, FetchResult};
pub use crawler::{CrawlConfig, CrawlResult, CrawlState, Crawler, PageResult};
pub use error::FetchError;
pub use http::HeaderMap;
pub use proxy::{parse_proxy_file, parse_proxy_line};
pub use sitemap::SitemapEntry;
pub use http::HeaderMap;
pub use webclaw_pdf::PdfMode;