From e797bffab9948016619a765839c3be67f2f13d8d Mon Sep 17 00:00:00 2001 From: Baitinq Date: Sat, 29 Oct 2022 00:32:01 +0200 Subject: Crawler+Indexer+Frontend: Rename structs to follow logical relations Now Resource is CrawledResource as it is created by the crawler, and the previous CrawledResource is now IndexedResource as its created by the indexer. --- frontend/src/main.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'frontend') diff --git a/frontend/src/main.rs b/frontend/src/main.rs index d2441d5..3d8bf51 100644 --- a/frontend/src/main.rs +++ b/frontend/src/main.rs @@ -11,7 +11,7 @@ use yew::prelude::*; //TODO: we should import this from the indexer #[derive(Debug, Clone, Deserialize)] -pub struct CrawledResource { +pub struct IndexedResource { url: String, title: String, description: String, @@ -20,26 +20,26 @@ pub struct CrawledResource { } //We implement PartialEq, Eq and Hash to ignore the priority field. -impl PartialEq for CrawledResource { +impl PartialEq for IndexedResource { fn eq(&self, other: &Self) -> bool { self.url == other.url && self.word == other.word } } -impl Eq for CrawledResource {} +impl Eq for IndexedResource {} -impl PartialOrd for CrawledResource { +impl PartialOrd for IndexedResource { fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } -impl Ord for CrawledResource { +impl Ord for IndexedResource { fn cmp(&self, other: &Self) -> Ordering { self.priority.cmp(&other.priority).reverse() } } -impl Hash for CrawledResource { +impl Hash for IndexedResource { fn hash(&self, state: &mut H) { self.url.hash(state); self.word.hash(state); @@ -48,7 +48,7 @@ impl Hash for CrawledResource { #[derive(Properties, Clone, PartialEq, Eq)] pub struct ResultComponentProps { - result: CrawledResource, + result: IndexedResource, } #[function_component(ResultComponent)] @@ -61,7 +61,7 @@ fn result_component(props: &ResultComponentProps) -> Html { #[derive(Debug, Clone)] struct State { pub search_query: String, - pub results: Option>, //TODO: some loading? + pub results: Option>, //TODO: some loading? } #[function_component(OSSE)] @@ -71,7 +71,7 @@ fn osse() -> Html { results: None, }); - let display_results = |maybe_results: &Option>| -> Html { + let display_results = |maybe_results: &Option>| -> Html { let maybe_results = maybe_results.as_ref(); if maybe_results.is_none() { return html! {}; @@ -128,7 +128,7 @@ fn osse() -> Html { let fetched_results = Request::get(endpoint.as_str()).send().await.unwrap(); - let fetched_json: Vec = match fetched_results.json().await { + let fetched_json: Vec = match fetched_results.json().await { Err(e) => panic!("Im panic: {}", e), Ok(json) => json, }; -- cgit 1.4.1