From 0222a19e9df3fa7b90ee429b02a053cc2210d9ea Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 8 Apr 2015 16:40:48 +0200 Subject: [PATCH] fix(version-up): v0.3.3 * hyper adjustments to deal with Client without type parameter * adjust to changed crate name conventions, '-' are converted to '_' Fixes #3 --- Cargo.toml | 2 +- examples/auth.rs | 4 ++-- src/device.rs | 17 ++++++----------- src/helper.rs | 18 ++++++------------ src/lib.rs | 6 +++--- src/refresh.rs | 13 ++++--------- 6 files changed, 22 insertions(+), 38 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1f11b3925..79b1c2524 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "yup-oauth2" -version = "0.3.2" +version = "0.3.3" authors = ["Sebastian Thiel "] repository = "https://github.com/Byron/yup-oauth2" description = "A partial oauth2 implementation, providing the 'device' authorization flow" diff --git a/examples/auth.rs b/examples/auth.rs index 21e57db08..a2b742025 100644 --- a/examples/auth.rs +++ b/examples/auth.rs @@ -1,7 +1,7 @@ #![feature(collections, old_io, std_misc, exit_status)] #![allow(deprecated)] -extern crate "yup-oauth2" as oauth2; -extern crate "yup-hyper-mock" as mock; +extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate hyper; extern crate chrono; extern crate getopts; diff --git a/src/device.rs b/src/device.rs index 4cb08bd2d..874d0a9e4 100644 --- a/src/device.rs +++ b/src/device.rs @@ -10,7 +10,6 @@ use itertools::Itertools; use rustc_serialize::json; use chrono::{DateTime,UTC}; use std::borrow::BorrowMut; -use std::marker::PhantomData; use std::io::Read; use common::{Token, FlowType, Flow}; @@ -21,17 +20,15 @@ pub const GOOGLE_TOKEN_URL: &'static str = "https://accounts.google.com/o/oauth2 /// It operates in two steps: /// * obtain a code to show to the user /// * (repeatedly) poll for the user to authenticate your application -pub struct DeviceFlow { +pub struct DeviceFlow { client: C, device_code: String, state: PollResult, secret: String, id: String, - - _m: PhantomData, } -impl Flow for DeviceFlow { +impl Flow for DeviceFlow { fn type_id() -> FlowType { FlowType::Device } @@ -103,28 +100,26 @@ impl Default for PollResult { } } -impl DeviceFlow - where C: BorrowMut>, - NC: hyper::net::NetworkConnector { +impl DeviceFlow + where C: BorrowMut { /// # Examples /// ```test_harness /// extern crate hyper; - /// extern crate "yup-oauth2" as oauth2; + /// extern crate yup_oauth2 as oauth2; /// use oauth2::DeviceFlow; /// /// # #[test] fn new() { /// let mut f = DeviceFlow::new(hyper::Client::new()); /// # } /// ``` - pub fn new(client: C) -> DeviceFlow { + pub fn new(client: C) -> DeviceFlow { DeviceFlow { client: client, device_code: Default::default(), secret: Default::default(), id: Default::default(), state: Default::default(), - _m: PhantomData, } } diff --git a/src/helper.rs b/src/helper.rs index 1652ec95a..ac900219d 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -1,6 +1,5 @@ use std::iter::IntoIterator; use std::borrow::BorrowMut; -use std::marker::PhantomData; use std::collections::HashMap; use std::hash::{SipHasher, Hash, Hasher}; use std::old_io::timer::sleep; @@ -70,14 +69,12 @@ impl TokenStorage for MemoryStorage { /// /// # Usage /// Please have a look at the library's landing page. -pub struct Authenticator { +pub struct Authenticator { flow_type: FlowType, delegate: D, storage: S, client: C, secret: ApplicationSecret, - - _m: PhantomData } /// A provider for authorization tokens, yielding tokens valid for a given scope. @@ -91,11 +88,10 @@ pub trait GetToken { fn api_key(&mut self) -> Option; } -impl Authenticator +impl Authenticator where D: AuthenticatorDelegate, S: TokenStorage, - NC: hyper::net::NetworkConnector, - C: BorrowMut> { + C: BorrowMut { /// Returns a new `Authenticator` instance @@ -113,14 +109,13 @@ impl Authenticator /// [dev-con]: https://console.developers.google.com pub fn new(secret: &ApplicationSecret, delegate: D, client: C, storage: S, flow_type: Option) - -> Authenticator { + -> Authenticator { Authenticator { flow_type: flow_type.unwrap_or(FlowType::Device), delegate: delegate, storage: storage, client: client, secret: secret.clone(), - _m: PhantomData } } @@ -181,11 +176,10 @@ impl Authenticator } } -impl GetToken for Authenticator +impl GetToken for Authenticator where D: AuthenticatorDelegate, S: TokenStorage, - NC: hyper::net::NetworkConnector, - C: BorrowMut> { + C: BorrowMut { /// Blocks until a token was retrieved from storage, from the server, or until the delegate /// decided to abort the attempt, or the user decided not to authorize the application. diff --git a/src/lib.rs b/src/lib.rs index 575cd1cf6..c996bb228 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,8 +16,8 @@ //! //! ```test_harness,no_run //! extern crate hyper; -//! extern crate "yup-oauth2" as oauth2; -//! extern crate "rustc-serialize" as rustc_serialize; +//! extern crate yup_oauth2 as oauth2; +//! extern crate rustc_serialize; //! //! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, PollInformation, ConsoleApplicationSecret, MemoryStorage, GetToken}; //! use rustc_serialize::json; @@ -47,7 +47,7 @@ //! //! ```test_harness,no_run //! extern crate hyper; -//! extern crate "yup-oauth2" as oauth2; +//! extern crate yup_oauth2 as oauth2; //! use oauth2::{RefreshFlow, FlowType, RefreshResult}; //! //! # #[test] fn refresh() { diff --git a/src/refresh.rs b/src/refresh.rs index 5b400ca75..2d5d3e4df 100644 --- a/src/refresh.rs +++ b/src/refresh.rs @@ -7,7 +7,6 @@ use rustc_serialize::json; use url::form_urlencoded; use super::Token; use std::borrow::BorrowMut; -use std::marker::PhantomData; use std::io::Read; /// Implements the [Outh2 Refresh Token Flow](https://developers.google.com/youtube/v3/guides/authentication#devices). @@ -15,11 +14,9 @@ use std::io::Read; /// Refresh an expired access token, as obtained by any other authentication flow. /// This flow is useful when your `Token` is expired and allows to obtain a new /// and valid access token. -pub struct RefreshFlow { +pub struct RefreshFlow { client: C, result: RefreshResult, - - _m: PhantomData, } @@ -33,15 +30,13 @@ pub enum RefreshResult { Success(Token), } -impl RefreshFlow - where NC: hyper::net::NetworkConnector, - C: BorrowMut> { +impl RefreshFlow + where C: BorrowMut { - pub fn new(client: C) -> RefreshFlow { + pub fn new(client: C) -> RefreshFlow { RefreshFlow { client: client, result: RefreshResult::Error(hyper::HttpError::HttpStatusError), - _m: PhantomData, } }