mirror of
https://github.com/neon-mmd/websurfx.git
synced 2024-11-22 05:58:21 -05:00
✨ feat: implement new fields, traits and functions (#201)
This commit is contained in:
parent
f4c496c02c
commit
410257c276
@ -102,13 +102,15 @@ impl EngineErrorInfo {
|
|||||||
/// and the type of error that caused it.
|
/// and the type of error that caused it.
|
||||||
/// * `empty_result_set` - Stores a boolean which indicates that no engines gave a result for the
|
/// * `empty_result_set` - Stores a boolean which indicates that no engines gave a result for the
|
||||||
/// given search query.
|
/// given search query.
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Default)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct SearchResults {
|
pub struct SearchResults {
|
||||||
pub results: Vec<SearchResult>,
|
pub results: Vec<SearchResult>,
|
||||||
pub page_query: String,
|
pub page_query: String,
|
||||||
pub style: Style,
|
pub style: Style,
|
||||||
pub engine_errors_info: Vec<EngineErrorInfo>,
|
pub engine_errors_info: Vec<EngineErrorInfo>,
|
||||||
|
pub disallowed: bool,
|
||||||
|
pub filtered: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SearchResults {
|
impl SearchResults {
|
||||||
@ -122,6 +124,7 @@ impl SearchResults {
|
|||||||
/// the search url.
|
/// the search url.
|
||||||
/// * `empty_result_set` - Takes a boolean which indicates that no engines gave a result for the
|
/// * `empty_result_set` - Takes a boolean which indicates that no engines gave a result for the
|
||||||
/// given search query.
|
/// given search query.
|
||||||
|
/// * ``
|
||||||
pub fn new(
|
pub fn new(
|
||||||
results: Vec<SearchResult>,
|
results: Vec<SearchResult>,
|
||||||
page_query: String,
|
page_query: String,
|
||||||
@ -130,13 +133,39 @@ impl SearchResults {
|
|||||||
SearchResults {
|
SearchResults {
|
||||||
results,
|
results,
|
||||||
page_query,
|
page_query,
|
||||||
style: Style::new("".to_string(), "".to_string()),
|
style: Style::default(),
|
||||||
engine_errors_info,
|
engine_errors_info,
|
||||||
|
disallowed: Default::default(),
|
||||||
|
filtered: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A setter function to add website style to the return search results.
|
/// A setter function to add website style to the return search results.
|
||||||
pub fn add_style(&mut self, style: Style) {
|
pub fn add_style(&mut self, style: &Style) {
|
||||||
self.style = style;
|
self.style = style.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A setter function that sets disallowed to true.
|
||||||
|
pub fn set_disallowed(&mut self) {
|
||||||
|
self.disallowed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A setter function to set the current page search query.
|
||||||
|
pub fn set_page_query(&mut self, page: &str) {
|
||||||
|
self.page_query = page.to_owned();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A setter function that sets the filtered to true.
|
||||||
|
pub fn set_filtered(&mut self) {
|
||||||
|
self.filtered = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A getter function that gets the value of `engine_errors_info`.
|
||||||
|
pub fn engine_errors_info(&mut self) -> Vec<EngineErrorInfo> {
|
||||||
|
std::mem::take(&mut self.engine_errors_info)
|
||||||
|
}
|
||||||
|
/// A getter function that gets the value of `results`.
|
||||||
|
pub fn results(&mut self) -> Vec<SearchResult> {
|
||||||
|
self.results.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user