Spaces:
Running
Running
neon_arch
commited on
Commit
·
141ae26
1
Parent(s):
47905f1
♻️ refactor: remove the code to add the `query` & `style` in the `SearchResults` struct & also remove the associated fields from the struct (#302)
Browse files
src/models/aggregation_models.rs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
| 1 |
//! This module provides public models for handling, storing and serializing of search results
|
| 2 |
//! data scraped from the upstream search engines.
|
| 3 |
|
|
|
|
| 4 |
use serde::{Deserialize, Serialize};
|
| 5 |
use smallvec::SmallVec;
|
| 6 |
|
| 7 |
-
use super::{engine_models::EngineError, parser_models::Style};
|
| 8 |
-
|
| 9 |
/// A named struct to store the raw scraped search results scraped search results from the
|
| 10 |
/// upstream search engines before aggregating it.It derives the Clone trait which is needed
|
| 11 |
/// to write idiomatic rust using `Iterators`.
|
|
@@ -109,10 +108,6 @@ impl EngineErrorInfo {
|
|
| 109 |
pub struct SearchResults {
|
| 110 |
/// Stores the individual serializable `SearchResult` struct into a vector of
|
| 111 |
pub results: Vec<SearchResult>,
|
| 112 |
-
/// Stores the current pages search query `q` provided in the search url.
|
| 113 |
-
pub page_query: String,
|
| 114 |
-
/// Stores the theming options for the website.
|
| 115 |
-
pub style: Style,
|
| 116 |
/// Stores the information on which engines failed with their engine name
|
| 117 |
/// and the type of error that caused it.
|
| 118 |
pub engine_errors_info: Vec<EngineErrorInfo>,
|
|
@@ -142,15 +137,9 @@ impl SearchResults {
|
|
| 142 |
/// the search url.
|
| 143 |
/// * `engine_errors_info` - Takes an array of structs which contains information regarding
|
| 144 |
/// which engines failed with their names, reason and their severity color name.
|
| 145 |
-
pub fn new(
|
| 146 |
-
results: Vec<SearchResult>,
|
| 147 |
-
page_query: &str,
|
| 148 |
-
engine_errors_info: &[EngineErrorInfo],
|
| 149 |
-
) -> Self {
|
| 150 |
Self {
|
| 151 |
results,
|
| 152 |
-
page_query: page_query.to_owned(),
|
| 153 |
-
style: Style::default(),
|
| 154 |
engine_errors_info: engine_errors_info.to_owned(),
|
| 155 |
disallowed: Default::default(),
|
| 156 |
filtered: Default::default(),
|
|
@@ -159,21 +148,11 @@ impl SearchResults {
|
|
| 159 |
}
|
| 160 |
}
|
| 161 |
|
| 162 |
-
/// A setter function to add website style to the return search results.
|
| 163 |
-
pub fn add_style(&mut self, style: &Style) {
|
| 164 |
-
self.style = style.clone();
|
| 165 |
-
}
|
| 166 |
-
|
| 167 |
/// A setter function that sets disallowed to true.
|
| 168 |
pub fn set_disallowed(&mut self) {
|
| 169 |
self.disallowed = true;
|
| 170 |
}
|
| 171 |
|
| 172 |
-
/// A setter function to set the current page search query.
|
| 173 |
-
pub fn set_page_query(&mut self, page: &str) {
|
| 174 |
-
self.page_query = page.to_owned();
|
| 175 |
-
}
|
| 176 |
-
|
| 177 |
/// A setter function that sets the filtered to true.
|
| 178 |
pub fn set_filtered(&mut self) {
|
| 179 |
self.filtered = true;
|
|
|
|
| 1 |
//! This module provides public models for handling, storing and serializing of search results
|
| 2 |
//! data scraped from the upstream search engines.
|
| 3 |
|
| 4 |
+
use super::engine_models::EngineError;
|
| 5 |
use serde::{Deserialize, Serialize};
|
| 6 |
use smallvec::SmallVec;
|
| 7 |
|
|
|
|
|
|
|
| 8 |
/// A named struct to store the raw scraped search results scraped search results from the
|
| 9 |
/// upstream search engines before aggregating it.It derives the Clone trait which is needed
|
| 10 |
/// to write idiomatic rust using `Iterators`.
|
|
|
|
| 108 |
pub struct SearchResults {
|
| 109 |
/// Stores the individual serializable `SearchResult` struct into a vector of
|
| 110 |
pub results: Vec<SearchResult>,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
/// Stores the information on which engines failed with their engine name
|
| 112 |
/// and the type of error that caused it.
|
| 113 |
pub engine_errors_info: Vec<EngineErrorInfo>,
|
|
|
|
| 137 |
/// the search url.
|
| 138 |
/// * `engine_errors_info` - Takes an array of structs which contains information regarding
|
| 139 |
/// which engines failed with their names, reason and their severity color name.
|
| 140 |
+
pub fn new(results: Vec<SearchResult>, engine_errors_info: &[EngineErrorInfo]) -> Self {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
Self {
|
| 142 |
results,
|
|
|
|
|
|
|
| 143 |
engine_errors_info: engine_errors_info.to_owned(),
|
| 144 |
disallowed: Default::default(),
|
| 145 |
filtered: Default::default(),
|
|
|
|
| 148 |
}
|
| 149 |
}
|
| 150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
/// A setter function that sets disallowed to true.
|
| 152 |
pub fn set_disallowed(&mut self) {
|
| 153 |
self.disallowed = true;
|
| 154 |
}
|
| 155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
/// A setter function that sets the filtered to true.
|
| 157 |
pub fn set_filtered(&mut self) {
|
| 158 |
self.filtered = true;
|