From 2a68081ae23ad7d2183f51e2112584b7cc74bd8e Mon Sep 17 00:00:00 2001 From: neon_arch Date: Sun, 27 Aug 2023 21:00:22 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20=20refactor:=20remove=20de?= =?UTF-8?q?precated=20intoreport=20functions=20&=20add=20minor=20optimizat?= =?UTF-8?q?ions=20(#180)(#178)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/engines/engine_models.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/engines/engine_models.rs b/src/engines/engine_models.rs index d33d13c..86fb207 100644 --- a/src/engines/engine_models.rs +++ b/src/engines/engine_models.rs @@ -2,7 +2,7 @@ //! the upstream search engines with the search query provided by the user. use crate::results::aggregation_models::SearchResult; -use error_stack::{IntoReport, Result, ResultExt}; +use error_stack::{Result, ResultExt}; use std::{collections::HashMap, fmt, time::Duration}; /// A custom error type used for handle engine associated errors. @@ -48,7 +48,7 @@ impl error_stack::Context for EngineError {} pub trait SearchEngine: Sync + Send { async fn fetch_html_from_upstream( &self, - url: String, + url: &str, header_map: reqwest::header::HeaderMap, request_timeout: u8, ) -> Result { @@ -59,19 +59,17 @@ pub trait SearchEngine: Sync + Send { .headers(header_map) // add spoofed headers to emulate human behavior .send() .await - .into_report() .change_context(EngineError::RequestError)? .text() .await - .into_report() .change_context(EngineError::RequestError)?) } async fn results( &self, - query: String, + query: &str, page: u32, - user_agent: String, + user_agent: &str, request_timeout: u8, ) -> Result, EngineError>; }