From 620d82cc3910d21940e9cc737900440be3b0ced4 Mon Sep 17 00:00:00 2001 From: Baitinq Date: Sun, 30 Oct 2022 12:59:46 +0100 Subject: Misc: Add local lib crate to share common structs --- indexer/src/main.rs | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) (limited to 'indexer/src') 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, -} - -//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(&self, state: &mut H) { - self.url.hash(state); - self.word.hash(state); - } -} +use lib::lib::*; struct AppState { database: Mutex>>, @@ -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, -- cgit 1.4.1