summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--twitch_api/src/client.rs17
-rw-r--r--twitch_api/src/helix/namespaces/videos.rs5
-rw-r--r--twitch_api/src/kraken/mod.rs1
-rw-r--r--twitch_api/src/lib.rs1
-rw-r--r--twitch_api/src/types.rs134
5 files changed, 7 insertions, 151 deletions
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<T: DeserializeOwned + 'static + Send> Future for ApiRequest<T> {
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<T: DeserializeOwned + 'static + Send> Future for ApiRequest<T> {
}
}
}
-} \ 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<Videos>;
@@ -9,19 +7,16 @@ type VideosNamespace = Namespace<Videos>;
impl VideosNamespace {
pub fn by_id<S: ToString>(self, ids: &[S])
-> IterableApiRequest<PaginationContainer<Video>> {
- use self::by_id;
by_id(self.client, ids)
}
pub fn by_user<S: ToString>(self, user_id: &S)
-> IterableApiRequest<PaginationContainer<Video>> {
- use self::by_user;
by_user(self.client, user_id)
}
pub fn for_game<S: ToString>(self, game_id: &S)
-> IterableApiRequest<PaginationContainer<Video>> {
- 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<User>;
-pub type ChannelId = UserId;
-pub type VideoId = StringId<Video>;
-pub type ClipId = StringId<Clip>;
-pub type GameId = StringId<Game>;
-
-#[derive(Clone)]
-pub struct StringId<T> {
- id: String,
- marker: PhantomData<T>
-}
-
-impl<T> StringId<T> {
- pub fn new(id: String) -> StringId<T> {
- StringId {
- id: id,
- marker: PhantomData,
- }
- }
-}
-
-impl<'a, T> StringId<T> {
-
- pub fn from_str(id: &'a str)
- -> Result<StringId<T>, !>
- {
- Ok(StringId::new(id.to_owned()))
- }
-}
-
-impl<'a, T> AsRef<str> for StringId<T> {
- fn as_ref(&self) -> &str {
- &self.id
- }
-}
-
-
-impl<'a, T> Into<&'a str> for &'a StringId<T> {
- fn into(self) -> &'a str {
- &self.id
- }
-}
-
-impl<T> Debug for StringId<T> {
- fn fmt(&self, f: &mut Formatter) -> fmt::Result
- {
- write!(f, "{:?}", &self.id)
- }
-}
-
-impl<T> PartialEq<StringId<T>> for StringId<T> {
- fn eq(&self, other: &StringId<T>) -> bool {
- self.id == other.id
- }
-}
-impl<T> Eq for StringId<T> {}
-
-impl<T> PartialEq<str> for StringId<T> {
- fn eq(&self, other: &str) -> bool {
- self.id.eq(other)
- }
-}
-
-use serde::{Deserialize, Deserializer};
-impl<'de, T> Deserialize<'de> for StringId<T> {
-
- fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
- where D: Deserializer<'de>
- {
- let id = String::deserialize(deserializer)?;
- Ok(StringId::new(id))
- }
-}
-
-use serde::{Serialize, Serializer};
-impl<'a, T> Serialize for StringId<T> {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- serializer.serialize_str(&self.id)
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::{UserId, VideoId};
- use std::str::FromStr;
- #[test]
- fn test_comparison() {
- let u1 = UserId::from_str("1234");
- let u2 = UserId::from_str("1234");
-
- assert_eq!(u1.is_ok(), true);
- assert_eq!(u2.is_ok(), true);
-
- let u1 = u1.unwrap();
- let u2 = u2.unwrap();
-
- assert_eq!(u1, u2);
- assert_eq!(&u1, "1234");
-
- let u2 = UserId::from_str("1235").unwrap();
- assert_ne!(u1, u2);
- assert_ne!(&u1, "1235");
-
- /* This must give a compile error */
- /*
- let v1 = VideoId::from_str("1234").unwrap();
- assert_ne!(v1, u1);
- */
- }
-
-}