|
@@ -11,7 +11,9 @@ use thesaurus::synonyms;
|
|
/// A named struct to store the raw scraped search results scraped search results from the
|
|
/// A named struct to store the raw scraped search results scraped search results from the
|
|
/// upstream search engines before aggregating it.It derives the Clone trait which is needed
|
|
/// upstream search engines before aggregating it.It derives the Clone trait which is needed
|
|
/// to write idiomatic rust using `Iterators`.
|
|
/// to write idiomatic rust using `Iterators`.
|
|
-/// (href url in html in simple words).
|
|
|
|
|
|
+///
|
|
|
|
+/// (href url in html in simple words).
|
|
|
|
+///
|
|
#[derive(Clone, Serialize, Deserialize)]
|
|
#[derive(Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct SearchResult {
|
|
pub struct SearchResult {
|
|
@@ -34,7 +36,7 @@ impl SearchResult {
|
|
///
|
|
///
|
|
/// * `title` - The title of the search result.
|
|
/// * `title` - The title of the search result.
|
|
/// * `url` - The url which is accessed when clicked on it
|
|
/// * `url` - The url which is accessed when clicked on it
|
|
- /// (href url in html in simple words).
|
|
|
|
|
|
+ /// (href url in html in simple words).
|
|
/// * `description` - The description of the search result.
|
|
/// * `description` - The description of the search result.
|
|
/// * `engine` - The names of the upstream engines from which this results were provided.
|
|
/// * `engine` - The names of the upstream engines from which this results were provided.
|
|
pub fn new(title: &str, url: &str, description: &str, engine: &[&str]) -> Self {
|
|
pub fn new(title: &str, url: &str, description: &str, engine: &[&str]) -> Self {
|
|
@@ -124,7 +126,7 @@ impl EngineErrorInfo {
|
|
/// # Arguments
|
|
/// # Arguments
|
|
///
|
|
///
|
|
/// * `error` - It takes the error type which occured while fetching the result from a particular
|
|
/// * `error` - It takes the error type which occured while fetching the result from a particular
|
|
- /// search engine.
|
|
|
|
|
|
+ /// search engine.
|
|
/// * `engine` - It takes the name of the engine that failed to provide the requested search results.
|
|
/// * `engine` - It takes the name of the engine that failed to provide the requested search results.
|
|
pub fn new(error: &EngineError, engine: &str) -> Self {
|
|
pub fn new(error: &EngineError, engine: &str) -> Self {
|
|
Self {
|
|
Self {
|
|
@@ -177,11 +179,11 @@ impl SearchResults {
|
|
/// # Arguments
|
|
/// # Arguments
|
|
///
|
|
///
|
|
/// * `results` - Takes an argument of individual serializable `SearchResult` struct
|
|
/// * `results` - Takes an argument of individual serializable `SearchResult` struct
|
|
- /// and stores it into a vector of `SearchResult` structs.
|
|
|
|
|
|
+ /// and stores it into a vector of `SearchResult` structs.
|
|
/// * `page_query` - Takes an argument of current page`s search query `q` provided in
|
|
/// * `page_query` - Takes an argument of current page`s search query `q` provided in
|
|
- /// the search url.
|
|
|
|
|
|
+ /// the search url.
|
|
/// * `engine_errors_info` - Takes an array of structs which contains information regarding
|
|
/// * `engine_errors_info` - Takes an array of structs which contains information regarding
|
|
- /// which engines failed with their names, reason and their severity color name.
|
|
|
|
|
|
+ /// which engines failed with their names, reason and their severity color name.
|
|
pub fn new(results: Box<[SearchResult]>, engine_errors_info: Box<[EngineErrorInfo]>) -> Self {
|
|
pub fn new(results: Box<[SearchResult]>, engine_errors_info: Box<[EngineErrorInfo]>) -> Self {
|
|
Self {
|
|
Self {
|
|
results,
|
|
results,
|