0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-22 14:08:23 -05:00
websurfx/src/search_results_handler/aggregation_models.rs

77 lines
1.5 KiB
Rust
Raw Normal View History

2023-04-22 07:35:07 -04:00
use serde::Serialize;
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SearchResult {
pub title: String,
pub visiting_url: String,
pub url: String,
pub description: String,
pub engine: Vec<String>,
}
impl SearchResult {
pub fn new(
title: String,
visiting_url: String,
url: String,
description: String,
engine: Vec<String>,
) -> Self {
SearchResult {
title,
visiting_url,
url,
description,
engine,
}
}
}
#[derive(Clone)]
2023-04-22 07:35:07 -04:00
pub struct RawSearchResult {
pub title: String,
pub visiting_url: String,
pub description: String,
pub engine: Vec<String>,
}
impl RawSearchResult {
pub fn new(
title: String,
visiting_url: String,
description: String,
engine: Vec<String>,
) -> Self {
RawSearchResult {
title,
visiting_url,
description,
engine,
}
}
pub fn add_engines(&mut self, engine: String) {
self.engine.push(engine)
}
pub fn engine(self) -> String {
self.engine.get(0).unwrap().to_string()
}
}
2023-04-22 07:35:07 -04:00
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SearchResults {
pub results: Vec<SearchResult>,
pub page_query: String,
}
impl SearchResults {
pub fn new(results: Vec<SearchResult>, page_query: String) -> Self {
SearchResults {
results,
page_query,
}
}
}