From f2e5041380330f46c1fcb29e29f128e1ba9fb047 Mon Sep 17 00:00:00 2001 From: David Blajda Date: Wed, 8 May 2019 16:01:44 +0000 Subject: Remove types from twitch_api --- twitch_api/src/client.rs | 17 ++-- twitch_api/src/helix/namespaces/videos.rs | 5 -- twitch_api/src/kraken/mod.rs | 1 - twitch_api/src/lib.rs | 1 - twitch_api/src/types.rs | 134 ------------------------------ 5 files changed, 7 insertions(+), 151 deletions(-) delete mode 100644 twitch_api/src/types.rs diff --git a/twitch_api/src/client.rs b/twitch_api/src/client.rs index 0307a05..1fe57e5 100644 --- a/twitch_api/src/client.rs +++ b/twitch_api/src/client.rs @@ -13,12 +13,10 @@ use futures::Poll; use serde::de::DeserializeOwned; use futures::Async; use futures::try_ready; -use serde_json::Value; use futures::future::Either; use crate::error::ConditionError; -pub use super::types; #[derive(PartialEq, Eq, Hash, Clone)] pub enum RatelimitKey { @@ -490,7 +488,6 @@ struct AuthStateRef { impl Client { pub fn new(id: &str, config: ClientConfig, version: Version) -> Client { - let client = ReqwestClient::new(); Client { inner: Arc::new( ClientType::Unauth(UnauthClient { @@ -538,11 +535,11 @@ impl Client { } /* The 'bottom' client must always be a client that is not authorized. - * This which allows for calls to Auth endpoints using the same control flow + * This allows for calls to Auth endpoints using the same control flow * as other requests. * - * Clients created with 'new' are bottom clients and calls - * to authenticate stack an authed client on top + * Clients created with 'new' are bottom clients. Calls to + * to 'authenticate' stack an authed client on top */ fn get_bottom_client(&self) -> Client { match self.inner.as_ref() { @@ -963,8 +960,8 @@ impl Waiter for RatelimitWaiter { } } -/* Macro ripped directly from try_ready and simplies retries if any error occurs - * and there are remaning retry attempt +/* Macro ripped directly from try_ready will retry the connection if any error occurs + * and there are remaning attempts */ #[macro_export] macro_rules! retry_ready { @@ -1129,7 +1126,7 @@ impl Future for ApiRequest { let client_cloned = client.clone(); /* Allow testing by capturing the request and returning a predetermined response - If testing is set in the client config then `Pending` is captured and saved and a future::ok(Resposne) is returned. + If testing is set in the client config then `Pending` is captured and saved and a future::ok(Response) is returned. */ let f = client.send(builder) @@ -1184,4 +1181,4 @@ impl Future for ApiRequest { } } } -} \ No newline at end of file +} diff --git a/twitch_api/src/helix/namespaces/videos.rs b/twitch_api/src/helix/namespaces/videos.rs index b603b8f..26886dd 100644 --- a/twitch_api/src/helix/namespaces/videos.rs +++ b/twitch_api/src/helix/namespaces/videos.rs @@ -1,7 +1,5 @@ use super::*; use super::models::{PaginationContainer, Video}; -use crate::types::{UserId, GameId, VideoId}; - pub struct Videos {} type VideosNamespace = Namespace; @@ -9,19 +7,16 @@ type VideosNamespace = Namespace; impl VideosNamespace { pub fn by_id(self, ids: &[S]) -> IterableApiRequest> { - use self::by_id; by_id(self.client, ids) } pub fn by_user(self, user_id: &S) -> IterableApiRequest> { - use self::by_user; by_user(self.client, user_id) } pub fn for_game(self, game_id: &S) -> IterableApiRequest> { - use self::for_game; for_game(self.client, game_id) } } diff --git a/twitch_api/src/kraken/mod.rs b/twitch_api/src/kraken/mod.rs index 4046377..2bf3b0c 100644 --- a/twitch_api/src/kraken/mod.rs +++ b/twitch_api/src/kraken/mod.rs @@ -1,7 +1,6 @@ use crate::client::Client as GenericClient; use crate::client::{Version, ClientConfig}; use crate::client::ClientTrait; -pub use super::types; use crate::client::{KrakenScope, Scope}; diff --git a/twitch_api/src/lib.rs b/twitch_api/src/lib.rs index 71e4855..ce062b5 100644 --- a/twitch_api/src/lib.rs +++ b/twitch_api/src/lib.rs @@ -11,7 +11,6 @@ extern crate twitch_types; pub mod helix; pub mod kraken; -pub mod types; pub mod error; mod sync; pub mod namespace; diff --git a/twitch_api/src/types.rs b/twitch_api/src/types.rs deleted file mode 100644 index e8ae2a3..0000000 --- a/twitch_api/src/types.rs +++ /dev/null @@ -1,134 +0,0 @@ -use std::convert::AsRef; -use std::cmp::{Eq, PartialEq}; -use std::marker::PhantomData; -use std::convert::Into; -use std::fmt; -use std::fmt::{Debug, Formatter}; - -/* Used for Id's that can be interpreted as integers but aren't returned as - * an int by Twitch's API. (Maybe to allow a quick switch to a different representation - * without breaking the json schema?) - * - * Don't Implement Display for StringID since it would allow comparisions between - * different StringId types - */ - -pub struct User {} -pub struct Video {} -pub struct Game {} -pub struct Clip {} - -pub type UserId = StringId; -pub type ChannelId = UserId; -pub type VideoId = StringId