From 98fb79b85e3cfbb547e5340b30623511daf09ef5 Mon Sep 17 00:00:00 2001 From: David Blajda Date: Wed, 8 May 2019 15:38:37 +0000 Subject: :WIP: Move types to a different crate --- src/helix/models.rs | 118 ---------------------------------------------------- 1 file changed, 118 deletions(-) delete mode 100644 src/helix/models.rs (limited to 'src/helix/models.rs') diff --git a/src/helix/models.rs b/src/helix/models.rs deleted file mode 100644 index 1e9f0ec..0000000 --- a/src/helix/models.rs +++ /dev/null @@ -1,118 +0,0 @@ -extern crate serde_json; -extern crate chrono; - -use url::Url; -use chrono::{DateTime, Utc}; -use crate::types::{UserId, VideoId, ChannelId}; - -use crate::client::PaginationTrait; - -#[derive(Debug, Deserialize, Serialize)] -pub struct DataContainer { - pub data: Vec -} - -impl PaginationTrait for DataContainer { - fn cursor<'a>(&'a self) -> Option<&'a str> { None } -} - -impl PaginationTrait for PaginationContainer { - fn cursor<'a>(&'a self) -> Option<&'a str> { - match self.pagination.as_ref() { - Some(cursor) => { - match cursor.cursor.as_ref() { - Some(cursor) => Some(cursor), - None => None, - } - }, - None => None - } - } -} - -impl PaginationTrait for Credentials { - fn cursor<'a>(&'a self) -> Option<&'a str> { None } -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct PaginationContainer { - pub data: Vec, - pub pagination: Option -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct Cursor { - pub cursor: Option -} - -#[derive(Debug, Deserialize, Serialize)] -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, - /*FIXME: Serde will attempt to parse an empty string. - * In this case this should be None when thumbnail_url is an empty string - */ - //#[serde(with = "url_serde")] - pub thumbnail_url: String, //Option, - 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, Serialize)] -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: String, // Option, - pub view_count: u32, - pub email: Option, -} - -#[derive(Debug, Deserialize, Serialize)] -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, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct Credentials { - pub access_token: String, - pub refresh_token: Option, - pub expires_in: u32, - pub scope: Option>, - pub token_type: String, -} -- cgit v1.2.3