use serde::{Deserialize, Serialize};
use std::collections::{HashMap, VecDeque};
use std::string::String;
use std::time::SystemTime;
use std::vec::Vec;
/// reprresent a media, it can be videos or books
#[derive(Deserialize, Serialize, Debug, Clone, Eq, PartialEq)]
pub struct Media {
    pub name: String,
    pub chapters: Vec<Chapter>,
    /// at which chapter the user is at
    pub cursor: Cursor,
    pub source: Option<String>,
}

/// location of the a chapter
#[derive(Deserialize, Serialize, Debug, Clone, Eq, PartialEq)]
pub enum Location {
    Internet(String),
    LocalDrive(String),
}

#[derive(Deserialize, Serialize, Debug, Clone, Eq, PartialEq)]
pub struct Chapter {
    pub name: String,
    pub locations: HashMap<String, Location>,
    pub number: usize,
}
/// Represent the current chapter's the user is in and the history of consumption
#[derive(Deserialize, Serialize, Debug, Clone, Eq, PartialEq, Default)]
pub struct Cursor {
    pub current: Option<Chapter>,
    pub history: VecDeque<(Chapter, SystemTime)>,
}
