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/Cargo.toml | 1 + indexer/src/main.rs | 33 +-------------------------------- 2 files changed, 2 insertions(+), 32 deletions(-) (limited to 'indexer') diff --git a/indexer/Cargo.toml b/indexer/Cargo.toml index 32355db..3627da8 100644 --- a/indexer/Cargo.toml +++ b/indexer/Cargo.toml @@ -13,6 +13,7 @@ scraper = "0.12.0" html2text = "0.4.3" rand = "0.7.3" serde_json = "1.0.87" +lib = { path = "../lib" } [[bin]] name = "indexer" 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