neon_arch commited on
Commit
410257c
1 Parent(s): f4c496c

✨ feat: implement new fields, traits and functions (#201)

Browse files
Files changed (1) hide show
  1. src/results/aggregation_models.rs +33 -4
src/results/aggregation_models.rs CHANGED
@@ -102,13 +102,15 @@ impl EngineErrorInfo {
102
  /// and the type of error that caused it.
103
  /// * `empty_result_set` - Stores a boolean which indicates that no engines gave a result for the
104
  /// given search query.
105
- #[derive(Serialize, Deserialize)]
106
  #[serde(rename_all = "camelCase")]
107
  pub struct SearchResults {
108
  pub results: Vec<SearchResult>,
109
  pub page_query: String,
110
  pub style: Style,
111
  pub engine_errors_info: Vec<EngineErrorInfo>,
 
 
112
  }
113
 
114
  impl SearchResults {
@@ -122,6 +124,7 @@ impl SearchResults {
122
  /// the search url.
123
  /// * `empty_result_set` - Takes a boolean which indicates that no engines gave a result for the
124
  /// given search query.
 
125
  pub fn new(
126
  results: Vec<SearchResult>,
127
  page_query: String,
@@ -130,13 +133,39 @@ impl SearchResults {
130
  SearchResults {
131
  results,
132
  page_query,
133
- style: Style::new("".to_string(), "".to_string()),
134
  engine_errors_info,
 
 
135
  }
136
  }
137
 
138
  /// A setter function to add website style to the return search results.
139
- pub fn add_style(&mut self, style: Style) {
140
- self.style = style;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  }
142
  }
 
102
  /// and the type of error that caused it.
103
  /// * `empty_result_set` - Stores a boolean which indicates that no engines gave a result for the
104
  /// given search query.
105
+ #[derive(Serialize, Deserialize, Default)]
106
  #[serde(rename_all = "camelCase")]
107
  pub struct SearchResults {
108
  pub results: Vec<SearchResult>,
109
  pub page_query: String,
110
  pub style: Style,
111
  pub engine_errors_info: Vec<EngineErrorInfo>,
112
+ pub disallowed: bool,
113
+ pub filtered: bool,
114
  }
115
 
116
  impl SearchResults {
 
124
  /// the search url.
125
  /// * `empty_result_set` - Takes a boolean which indicates that no engines gave a result for the
126
  /// given search query.
127
+ /// * ``
128
  pub fn new(
129
  results: Vec<SearchResult>,
130
  page_query: String,
 
133
  SearchResults {
134
  results,
135
  page_query,
136
+ style: Style::default(),
137
  engine_errors_info,
138
+ disallowed: Default::default(),
139
+ filtered: Default::default(),
140
  }
141
  }
142
 
143
  /// A setter function to add website style to the return search results.
144
+ pub fn add_style(&mut self, style: &Style) {
145
+ self.style = style.clone();
146
+ }
147
+
148
+ /// A setter function that sets disallowed to true.
149
+ pub fn set_disallowed(&mut self) {
150
+ self.disallowed = true;
151
+ }
152
+
153
+ /// A setter function to set the current page search query.
154
+ pub fn set_page_query(&mut self, page: &str) {
155
+ self.page_query = page.to_owned();
156
+ }
157
+
158
+ /// A setter function that sets the filtered to true.
159
+ pub fn set_filtered(&mut self) {
160
+ self.filtered = true;
161
+ }
162
+
163
+ /// A getter function that gets the value of `engine_errors_info`.
164
+ pub fn engine_errors_info(&mut self) -> Vec<EngineErrorInfo> {
165
+ std::mem::take(&mut self.engine_errors_info)
166
+ }
167
+ /// A getter function that gets the value of `results`.
168
+ pub fn results(&mut self) -> Vec<SearchResult> {
169
+ self.results.clone()
170
  }
171
  }