neon_arch
commited on
Commit
•
2a68081
1
Parent(s):
f5f0488
⚙️ refactor: remove deprecated intoreport functions & add minor optimizations (#180)(#178)
Browse files
src/engines/engine_models.rs
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
//! the upstream search engines with the search query provided by the user.
|
3 |
|
4 |
use crate::results::aggregation_models::SearchResult;
|
5 |
-
use error_stack::{
|
6 |
use std::{collections::HashMap, fmt, time::Duration};
|
7 |
|
8 |
/// A custom error type used for handle engine associated errors.
|
@@ -48,7 +48,7 @@ impl error_stack::Context for EngineError {}
|
|
48 |
pub trait SearchEngine: Sync + Send {
|
49 |
async fn fetch_html_from_upstream(
|
50 |
&self,
|
51 |
-
url:
|
52 |
header_map: reqwest::header::HeaderMap,
|
53 |
request_timeout: u8,
|
54 |
) -> Result<String, EngineError> {
|
@@ -59,19 +59,17 @@ pub trait SearchEngine: Sync + Send {
|
|
59 |
.headers(header_map) // add spoofed headers to emulate human behavior
|
60 |
.send()
|
61 |
.await
|
62 |
-
.into_report()
|
63 |
.change_context(EngineError::RequestError)?
|
64 |
.text()
|
65 |
.await
|
66 |
-
.into_report()
|
67 |
.change_context(EngineError::RequestError)?)
|
68 |
}
|
69 |
|
70 |
async fn results(
|
71 |
&self,
|
72 |
-
query:
|
73 |
page: u32,
|
74 |
-
user_agent:
|
75 |
request_timeout: u8,
|
76 |
) -> Result<HashMap<String, SearchResult>, EngineError>;
|
77 |
}
|
|
|
2 |
//! the upstream search engines with the search query provided by the user.
|
3 |
|
4 |
use crate::results::aggregation_models::SearchResult;
|
5 |
+
use error_stack::{Result, ResultExt};
|
6 |
use std::{collections::HashMap, fmt, time::Duration};
|
7 |
|
8 |
/// A custom error type used for handle engine associated errors.
|
|
|
48 |
pub trait SearchEngine: Sync + Send {
|
49 |
async fn fetch_html_from_upstream(
|
50 |
&self,
|
51 |
+
url: &str,
|
52 |
header_map: reqwest::header::HeaderMap,
|
53 |
request_timeout: u8,
|
54 |
) -> Result<String, EngineError> {
|
|
|
59 |
.headers(header_map) // add spoofed headers to emulate human behavior
|
60 |
.send()
|
61 |
.await
|
|
|
62 |
.change_context(EngineError::RequestError)?
|
63 |
.text()
|
64 |
.await
|
|
|
65 |
.change_context(EngineError::RequestError)?)
|
66 |
}
|
67 |
|
68 |
async fn results(
|
69 |
&self,
|
70 |
+
query: &str,
|
71 |
page: u32,
|
72 |
+
user_agent: &str,
|
73 |
request_timeout: u8,
|
74 |
) -> Result<HashMap<String, SearchResult>, EngineError>;
|
75 |
}
|