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>,
|
|
|
|
}
|
|
|
|
|
2023-04-25 09:30:04 -04:00
|
|
|
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,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-26 10:46:49 -04:00
|
|
|
#[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>,
|
|
|
|
}
|
|
|
|
|
2023-04-25 09:30:04 -04:00
|
|
|
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)
|
|
|
|
}
|
2023-04-26 10:46:49 -04:00
|
|
|
|
|
|
|
pub fn engine(self) -> String {
|
|
|
|
self.engine.get(0).unwrap().to_string()
|
|
|
|
}
|
2023-04-25 09:30:04 -04:00
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
}
|
2023-04-25 09:30:04 -04:00
|
|
|
|
|
|
|
impl SearchResults {
|
|
|
|
pub fn new(results: Vec<SearchResult>, page_query: String) -> Self {
|
|
|
|
SearchResults {
|
|
|
|
results,
|
|
|
|
page_query,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|