about summary refs log tree commit diff
path: root/indexer/src
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2022-10-30 12:59:46 +0100
committerBaitinq <manuelpalenzuelamerino@gmail.com>2022-10-30 12:59:46 +0100
commit620d82cc3910d21940e9cc737900440be3b0ced4 (patch)
tree82f8b4b9e93deed5f72a61c5784d6fff5c5bc971 /indexer/src
parentFrontend: Add props to the OSSE Component (diff)
downloadOSSE-620d82cc3910d21940e9cc737900440be3b0ced4.tar.gz
OSSE-620d82cc3910d21940e9cc737900440be3b0ced4.tar.bz2
OSSE-620d82cc3910d21940e9cc737900440be3b0ced4.zip
Misc: Add local lib crate to share common structs
Diffstat (limited to 'indexer/src')
-rw-r--r--indexer/src/main.rs33
1 files changed, 1 insertions, 32 deletions
diff --git a/indexer/src/main.rs b/indexer/src/main.rs
index 825fe4d..18604a6 100644
--- a/indexer/src/main.rs
+++ b/indexer/src/main.rs
@@ -1,32 +1,8 @@
 use actix_cors::Cors;
 use actix_web::{get, post, web, App, HttpServer, Responder};
-use serde::{Deserialize, Serialize};
 use std::collections::{HashMap, HashSet};
-use std::hash::{Hash, Hasher};
 use std::sync::{Arc, Mutex};
-
-#[derive(Debug, Clone, Serialize)]
-struct IndexedResource {
-    url: String,
-    title: String,
-    description: String,
-    priority: u32,
-    word: Arc<String>,
-}
-
-//We implement PartialEq, Eq and Hash to ignore the priority field.
-impl PartialEq for IndexedResource {
-    fn eq(&self, other: &Self) -> bool {
-        self.url == other.url && self.word == other.word
-    }
-}
-impl Eq for IndexedResource {}
-impl Hash for IndexedResource {
-    fn hash<H: Hasher>(&self, state: &mut H) {
-        self.url.hash(state);
-        self.word.hash(state);
-    }
-}
+use lib::lib::*;
 
 struct AppState {
     database: Mutex<HashMap<String, HashSet<IndexedResource>>>,
@@ -58,13 +34,6 @@ async fn serve_http_endpoint(address: &str, port: u16) -> std::io::Result<()> {
 }
 
 //TODO: sufficiently simmilar word in search (algorithm)
-//we need to rename stuff
-#[derive(Deserialize, Debug)]
-struct CrawledResource {
-    url: String,
-    content: String,
-}
-
 #[post("/resource")]
 async fn add_resource(
     data: web::Data<AppState>,