diff options
author | David Blajda <blajda@hotmail.com> | 2018-12-15 06:21:52 +0000 |
---|---|---|
committer | David Blajda <blajda@hotmail.com> | 2018-12-15 06:21:52 +0000 |
commit | a4c842eae14bef20d3d04ee4313251344edf431f (patch) | |
tree | 1685f11fd6bbe9f85cb51d479770b04692250c0c /src/kraken/models.rs | |
parent | 8615cc2f030240ba2982dba893fe63f11a0c8a88 (diff) |
Deserialize Urls and Dates. Also implement custom Id types
Diffstat (limited to 'src/kraken/models.rs')
-rw-r--r-- | src/kraken/models.rs | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/kraken/models.rs b/src/kraken/models.rs index 13c524c..4863641 100644 --- a/src/kraken/models.rs +++ b/src/kraken/models.rs @@ -1,12 +1,19 @@ extern crate serde_json; extern crate chrono; +extern crate url; + +use url::Url; +use chrono::{DateTime, Utc}; +use super::types::{UserId, VideoId}; #[derive(Debug, Deserialize)] pub struct Clip { pub slug: String, pub tracking_id: String, - pub url: String, - pub embed_url: String, + #[serde(with = "url_serde")] + pub url: Url, + #[serde(with = "url_serde")] + pub embed_url: Url, pub embed_html: String, pub broadcaster: UserData, pub curator: UserData, @@ -16,29 +23,34 @@ pub struct Clip { pub title: String, pub views: i32, pub duration: f32, - pub created_at: String, + pub created_at: DateTime<Utc>, pub thumbnails: Thumbnails, } #[derive(Debug, Deserialize)] pub struct Thumbnails { - pub medium: String, - pub small: String, - pub tiny: String, + #[serde(with = "url_serde")] + pub medium: Url, + #[serde(with = "url_serde")] + pub small: Url, + #[serde(with = "url_serde")] + pub tiny: Url, } #[derive(Debug, Deserialize)] pub struct UserData { - pub id: String, + pub id: UserId, pub name: String, pub display_name: String, - pub channel_url: String, + #[serde(with = "url_serde")] + pub channel_url: Url, pub logo: String, } #[derive(Debug, Deserialize)] pub struct Vod { - pub id: String, - pub url: String, + pub id: VideoId, + #[serde(with = "url_serde")] + pub url: Url, } |