From df50f3607db2d547da98d2e3abc7c72e59a8d6c0 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Mon, 14 Mar 2022 19:47:03 +0000 Subject: [PATCH] Reformat --- quickpeep/src/raking.rs | 43 ++++++++++++++++++++++------------- quickpeep_densedoc/src/lib.rs | 2 +- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/quickpeep/src/raking.rs b/quickpeep/src/raking.rs index d8735d1..f2ca1a8 100644 --- a/quickpeep/src/raking.rs +++ b/quickpeep/src/raking.rs @@ -43,7 +43,7 @@ pub enum RedirectReason { /// The page redirected somewhere else. Redirected { /// HTTP Status Code of the redirect - http_code: u16 + http_code: u16, }, /// The page was not canonical, and should not be indexed. NotCanonical, @@ -163,33 +163,38 @@ impl Raker { if response.status().is_redirection() { if let Some(redirect_target) = response.headers().get("location") { - let new_url = url.join(redirect_target.to_str() - .context("Failed to convert Location header to str")?) + let new_url = url + .join( + redirect_target + .to_str() + .context("Failed to convert Location header to str")?, + ) .context("Failed to resolve Location header target")?; return Ok(RakeOutcome::Redirect { - reason: RedirectReason::Redirected { - http_code - }, - new_url + reason: RedirectReason::Redirected { http_code }, + new_url, }); } else { - bail!("Redirection {:?} received, but no Location header.", response.status()); + bail!( + "Redirection {:?} received, but no Location header.", + response.status() + ); } } if response.status().is_client_error() { return Ok(RakeOutcome::PermanentFailure(PermanentFailure { - reason: PermanentFailureReason::ResourceDenied(http_code) - })) + reason: PermanentFailureReason::ResourceDenied(http_code), + })); } if response.status().is_server_error() { return Ok(RakeOutcome::TemporaryFailure(TemporaryFailure { reason: TemporaryFailureReason::ServerError(http_code), // Try again tomorrow. Maybe the server is overloaded? - backoff_sec: 86400 - })) + backoff_sec: 86400, + })); } if !response.status().is_success() { @@ -254,7 +259,12 @@ impl Raker { })); } - pub fn rake_html_page(&self, content: &[u8], url: &Url, is_cf: bool) -> anyhow::Result { + pub fn rake_html_page( + &self, + content: &[u8], + url: &Url, + is_cf: bool, + ) -> anyhow::Result { let content_str = std::str::from_utf8(content)?; let root_node: NodeRef = kuchiki::parse_html().one(content_str); @@ -263,13 +273,14 @@ impl Raker { // If it's not, then we redirect the raker to the canonical URL. if let Ok(canonical_link_node) = root_node.select_first("head link[rel=canonical]") { if let Some(canonical_href) = canonical_link_node.attributes.borrow().get("href") { - let canonical_url = url.join(canonical_href) + let canonical_url = url + .join(canonical_href) .context("Failed to resolve or parse canonical URL")?; if &canonical_url != url { return Ok(RakeOutcome::Redirect { reason: RedirectReason::NotCanonical, - new_url: canonical_url + new_url: canonical_url, }); } } @@ -310,7 +321,7 @@ impl Raker { eprintln!("{:#?}", readability.metadata); - if let Some(node) = readability.article_node { + if let Some(_node) = readability.article_node { //eprintln!("{}", node.to_string()); } diff --git a/quickpeep_densedoc/src/lib.rs b/quickpeep_densedoc/src/lib.rs index f92f4e2..e405883 100644 --- a/quickpeep_densedoc/src/lib.rs +++ b/quickpeep_densedoc/src/lib.rs @@ -12,7 +12,7 @@ pub struct DenseDocument { } impl DenseDocument { - pub fn from_document(root_node: NodeRef) { + pub fn from_document(_root_node: NodeRef) { todo!() } }