extern crate serde_json; extern crate chrono; use url::Url; use chrono::{DateTime, Utc}; use super::types::{UserId, VideoId, ChannelId}; pub trait PaginationTrait { fn cursor<'a>(&'a self) -> &'a Option; } #[derive(Debug, Deserialize)] pub struct DataContainer { pub data: Vec } impl PaginationTrait for DataContainer { fn cursor<'a>(&'a self) -> &'a Option { &None } } impl PaginationTrait for PaginationContainer { fn cursor<'a>(&'a self) -> &'a Option { &self.pagination } } impl PaginationTrait for Credentials { fn cursor<'a>(&'a self) -> &'a Option { &None } } #[derive(Debug, Deserialize)] pub struct PaginationContainer { pub data: Vec, pub pagination: Option } #[derive(Debug, Deserialize)] pub struct Cursor { pub cursor: Option } #[derive(Debug, Deserialize)] pub struct Credentials { pub access_token: String, pub refresh_token: Option, pub expires_in: u32, pub scope: Option>, pub token_type: String, } #[derive(Debug, Deserialize)] pub struct Video { pub id: VideoId, pub user_id: UserId, pub user_name: String, pub title: String, pub description: String, pub created_at: DateTime, pub published_at: DateTime, #[serde(with = "url_serde")] pub url: Url, #[serde(with = "url_serde")] pub thumbnail_url: Url, pub viewable: String, pub view_count: i32, pub language: String, #[serde(rename = "type")] pub video_type: String, //Should be converted to a Duration pub duration: String, } #[derive(Debug, Deserialize)] pub struct User { pub id: UserId, pub login: String, pub display_name: String, #[serde(rename = "type")] pub user_type: String, pub broadcaster_type: String, pub description: String, #[serde(with = "url_serde")] pub profile_image_url: Url, #[serde(with = "url_serde")] pub offline_image_url: Url, pub view_count: u32, pub email: Option, } #[derive(Debug, Deserialize)] pub struct Clip { pub id: String, #[serde(with = "url_serde")] pub url: Url, #[serde(with = "url_serde")] pub embed_url: Url, pub broadcaster_id: ChannelId, pub broadcaster_name: String, pub creator_id: UserId, pub creator_name: String, pub video_id: VideoId, pub game_id: String, pub language: String, pub title: String, pub created_at: DateTime, #[serde(with = "url_serde")] pub thumbnail_url: Url, pub view_count: i32, }