From 27f337f63ab97892bd11ff2aefa55f32874c86ba Mon Sep 17 00:00:00 2001 From: shockrah Date: Mon, 27 Sep 2021 21:03:27 -0700 Subject: [PATCH] + Adding Videos field to json store Basically the json store keeps the keys _and_ the meta data for the videos At some we'll change this however this would be a dblib only change --- dblib/src/lib.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/dblib/src/lib.rs b/dblib/src/lib.rs index ba3c3a6..9d27441 100644 --- a/dblib/src/lib.rs +++ b/dblib/src/lib.rs @@ -6,6 +6,7 @@ use serde::{Serialize, Deserialize}; pub mod request; pub mod keystore; +pub mod videostore; pub mod err; use request::ApiKey; @@ -25,15 +26,22 @@ fn dev_urandom() -> std::io::Result { #[derive(Serialize, Deserialize)] pub struct VideoMeta { - pub id: u64, - pub string: String, + pub id: String, + pub name: String, + pub desc: Option +} + +#[derive(Serialize, Deserialize)] +struct VideoMetaEntry { + pub name: String, pub desc: Option } #[derive(Serialize, Deserialize)] pub struct DB { keys: Vec, - videos: HashMap + // We map the video meta id to its actual body content + videos: HashMap } // TODO: add some proper lifetime management here and some docs @@ -46,8 +54,8 @@ pub trait KeyStore { pub trait VideoStore { fn new_video(name: &str, desc: &str) -> err::Result<()>; - fn del_video(id: u64) -> err::Result<()>; - fn get_video(id: Option, name: Option<&str>) -> err::Result; - fn rename_video(id: u64, new: &str) -> err::Result<()>; - fn redescribe_video(id: u64, new: &str) -> err::Result<()>; + fn del_video(id: String) -> err::Result<()>; + fn get_video(id: Option, name: Option<&str>) -> err::Result; + fn rename_video(id: String, new: &str) -> err::Result<()>; + fn redescribe_video(id: String, new: &str) -> err::Result<()>; }