diff --git a/service/src/db.rs b/service/src/db.rs index c662f01..76aa9b5 100644 --- a/service/src/db.rs +++ b/service/src/db.rs @@ -8,23 +8,23 @@ use crate::CONFIG; #[derive(Serialize, Deserialize)] pub struct Row { - pub id: i64, pub file: String, pub thumbnail: String } +type Data = HashMap; -pub fn get_video(id: i64) -> Option { + +pub fn get_video(id: String) -> Option { // Used to fetch video information from the db for client's to request // video and thumbnail files from us let db_file = fs::read_to_string(CONFIG.db_file) .expect("Unable to read DB_FILE"); - let db_data: HashMap = json::from_str(&db_file) + let db_data: Data = json::from_str(&db_file) .expect("Unable to parse DB_FILE content"); match db_data.get(&id) { Some(video) => Some(Row { - id, file: video.file.clone(), thumbnail: video.thumbnail.clone() }), diff --git a/service/src/video.rs b/service/src/video.rs index 4c69ed9..4b852a2 100644 --- a/service/src/video.rs +++ b/service/src/video.rs @@ -5,7 +5,7 @@ use rocket_dyn_templates::Template; use rocket_dyn_templates::context; #[get("/")] -pub fn index(video_id: i64) -> Template { +pub fn index(video_id: String) -> Template { // Read the db file we have to get the ID // Now we can fetch the row from the DB content match db::get_video(video_id) {