use crate::global::{ structs::Item, traits::{Collection, CollectionNoId}, }; use serde::{Deserialize, Serialize}; use typemap::Key; #[derive(Clone, Default, Serialize, Deserialize)] pub struct WatchHistory(pub Vec); impl Key for WatchHistory { type Value = Self; } impl Collection for WatchHistory { const INDEX_PATH: &'static str = ".local/share/youtube-tui/watch_history.json"; fn items(&self) -> &Vec { &self.0 } fn items_mut(&mut self) -> &mut Vec { &mut self.0 } fn from_items(items: Vec) -> Self { Self(items) } } #[derive(Clone, Default, Serialize, Deserialize)] pub struct SearchHistory(pub Vec); impl Key for SearchHistory { type Value = Self; } impl CollectionNoId for SearchHistory { const INDEX_PATH: &'static str = ".local/share/youtube-tui/search_history.json"; fn items(&self) -> &Vec { &self.0 } fn items_mut(&mut self) -> &mut Vec { &mut self.0 } fn from_items(items: Vec) -> Self { Self(items) } } #[derive(Clone, Default, Serialize, Deserialize)] pub struct CommandHistory(pub Vec); impl Key for CommandHistory { type Value = Self; } impl CollectionNoId for CommandHistory { const INDEX_PATH: &'static str = ".local/share/youtube-tui/command_history.json"; fn items(&self) -> &Vec { &self.0 } fn items_mut(&mut self) -> &mut Vec { &mut self.0 } fn from_items(items: Vec) -> Self { Self(items) } } /* #[derive(Clone, Default, Serialize, Deserialize)] pub struct ChannelHistory(pub Vec); impl Key for ChannelHistory { type Value = Self; } impl CollectionNoId for ChannelHistory { const INDEX_PATH: &'static str = ".local/share/youtube-tui/channel_history.json"; fn items(&self) -> &Vec { &self.0 } fn items_mut(&mut self) -> &mut Vec { &mut self.0 } fn from_items(items: Vec) -> Self { Self(items) } } */