From 70629ed0dc950d4f1c83ef15a6b4b65700338d3d Mon Sep 17 00:00:00 2001 From: David Blajda Date: Sun, 30 Dec 2018 20:08:09 +0000 Subject: :WIP: Reworking types --- src/bin/main.rs | 9 +++++ src/client.rs | 1 + src/helix/models.rs | 12 +++---- src/kraken/models.rs | 4 +-- src/types.rs | 95 +++++++++++++++++++++++++--------------------------- 5 files changed, 63 insertions(+), 58 deletions(-) diff --git a/src/bin/main.rs b/src/bin/main.rs index 15b7753..9be688b 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -68,6 +68,12 @@ fn main() { () }); + let u = helix_client + .users() + .users(vec!(), vec!("freakey")) + .map(|res| {println!("{:?}", res); ()}) + .map_err(|res| {println!("{:?}", res); ()}); + /* Prevents tokio from **hanging** * since tokio::run blocks the current thread and waits for the entire runtime * to become idle but it will never becomes idle since we keep a reference @@ -75,6 +81,8 @@ fn main() { */ //std::mem::drop(authed_client); tokio::run( + u + /* clip.join(clip2) .and_then(|(c1, c2)| { println!("{:?}", c1); @@ -93,6 +101,7 @@ fn main() { }) .map(|_| ()) .map_err(|_| ()) + */ /*videos*/ ); } diff --git a/src/client.rs b/src/client.rs index 3371670..66f32d6 100644 --- a/src/client.rs +++ b/src/client.rs @@ -882,6 +882,7 @@ impl Future for ApiRequest { err }) .map(move |mut response| { + println!("{:?}", response); if let Some(key) = key_ok { if let Some(limits) = client_ok.ratelimit(key) { let mut mut_limits = limits.inner.lock().unwrap(); diff --git a/src/helix/models.rs b/src/helix/models.rs index 5a35869..af221bc 100644 --- a/src/helix/models.rs +++ b/src/helix/models.rs @@ -47,8 +47,8 @@ pub struct Cursor { #[derive(Debug, Deserialize)] pub struct Video { - pub id: VideoId, - pub user_id: UserId, + pub id: VideoId<'static>, + pub user_id: UserId<'static>, pub user_name: String, pub title: String, pub description: String, @@ -72,7 +72,7 @@ pub struct Video { #[derive(Debug, Deserialize)] pub struct User { - pub id: UserId, + pub id: UserId<'static>, pub login: String, pub display_name: String, #[serde(rename = "type")] @@ -94,11 +94,11 @@ pub struct Clip { pub url: Url, #[serde(with = "url_serde")] pub embed_url: Url, - pub broadcaster_id: ChannelId, + pub broadcaster_id: ChannelId<'static>, pub broadcaster_name: String, - pub creator_id: UserId, + pub creator_id: UserId<'static>, pub creator_name: String, - pub video_id: VideoId, + pub video_id: VideoId<'static>, pub game_id: String, pub language: String, pub title: String, diff --git a/src/kraken/models.rs b/src/kraken/models.rs index 8b5b6d6..d6a6e4f 100644 --- a/src/kraken/models.rs +++ b/src/kraken/models.rs @@ -45,7 +45,7 @@ pub struct Thumbnails { #[derive(Debug, Deserialize)] pub struct UserData { - pub id: UserId, + pub id: UserId<'static>, pub name: String, pub display_name: String, #[serde(with = "url_serde")] @@ -55,7 +55,7 @@ pub struct UserData { #[derive(Debug, Deserialize)] pub struct Vod { - pub id: VideoId, + pub id: VideoId<'static>, #[serde(with = "url_serde")] pub url: Url, } diff --git a/src/types.rs b/src/types.rs index f59fd3a..eeede15 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,6 +1,5 @@ use std::convert::AsRef; use std::str::FromStr; -use std::sync::Arc; use std::cmp::{Eq, PartialEq}; use std::marker::PhantomData; @@ -13,109 +12,105 @@ pub struct User {} pub struct Video {} pub struct Game {} -pub type UserId = IntegerId; -pub type ChannelId = UserId; -pub type VideoId = IntegerId