+ 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
This commit is contained in:
shockrah 2021-09-27 21:03:27 -07:00
parent 3623a8236f
commit 27f337f63a

View File

@ -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<String> {
#[derive(Serialize, Deserialize)]
pub struct VideoMeta {
pub id: u64,
pub string: String,
pub id: String,
pub name: String,
pub desc: Option<String>
}
#[derive(Serialize, Deserialize)]
struct VideoMetaEntry {
pub name: String,
pub desc: Option<String>
}
#[derive(Serialize, Deserialize)]
pub struct DB {
keys: Vec<ApiKey>,
videos: HashMap<String, VideoMeta>
// We map the video meta id to its actual body content
videos: HashMap<String, VideoMetaEntry>
}
// 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<u64>, name: Option<&str>) -> err::Result<VideoMeta>;
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<String>, name: Option<&str>) -> err::Result<VideoMeta>;
fn rename_video(id: String, new: &str) -> err::Result<()>;
fn redescribe_video(id: String, new: &str) -> err::Result<()>;
}