src/global/structs/watchhistory.rs
26 lines · 591 bytes
1use crate::global::{structs::Item, traits::Collection};
2use serde::{Deserialize, Serialize};
3use typemap::Key;
4
5#[derive(Clone, Default, Serialize, Deserialize)]
6pub struct WatchHistory(pub Vec<Item>);
7
8impl Key for WatchHistory {
9 type Value = Self;
10}
11
12impl Collection<Item> for WatchHistory {
13 const INDEX_PATH: &'static str = ".local/share/youtube-tui/watch_history.json";
14
15 fn items(&self) -> &Vec<Item> {
16 &self.0
17 }
18
19 fn items_mut(&mut self) -> &mut Vec<Item> {
20 &mut self.0
21 }
22
23 fn from_items(items: Vec<Item>) -> Self {
24 Self(items)
25 }
26}