Skip to content

Commit

Permalink
fix(update-dependencies): rustup + dep-up
Browse files Browse the repository at this point in the history
* updated to rustc (be9bd7c93 2015-04-05)
* use latest hyper

The latter required us to deal with HttpError not being clonable
anymore.
  • Loading branch information
Byron committed Apr 7, 2015
1 parent feba2d0 commit 2489b81
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "yup-oauth2"
version = "0.3.1"
version = "0.3.2"
authors = ["Sebastian Thiel <byronimo@gmail.com>"]
repository = "https://github.com/Byron/yup-oauth2"
description = "A partial oauth2 implementation, providing the 'device' authorization flow"
Expand All @@ -20,5 +20,5 @@ rustc-serialize = "*"

[dev-dependencies]
getopts = "*"
yup-hyper-mock = ">= 0.1.3"
yup-hyper-mock = ">= 0.1.4"
open = "*"
4 changes: 2 additions & 2 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub struct Scheme {
}

impl hyper::header::Scheme for Scheme {
fn scheme(_: Option<Scheme>) -> Option<&'static str> {
fn scheme() -> Option<&'static str> {
None
}

Expand Down Expand Up @@ -128,7 +128,7 @@ impl Token {
}

/// All known authentication types, for suitable constants
#[derive(Copy)]
#[derive(Clone, Copy)]
pub enum FlowType {
/// [device authentication](https://developers.google.com/youtube/v3/guides/authentication#devices)
Device,
Expand Down
11 changes: 6 additions & 5 deletions src/device.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::iter::IntoIterator;
use std::time::Duration;
use std::default::Default;
use std::rc::Rc;

use hyper;
use hyper::header::ContentType;
Expand Down Expand Up @@ -61,7 +62,7 @@ pub struct PollInformation {
#[derive(Clone)]
pub enum RequestResult {
/// Indicates connection failure
Error(hyper::HttpError),
Error(Rc<hyper::HttpError>),
/// The OAuth client was not found
InvalidClient,
/// Some requested scopes were invalid. String contains the scopes as part of
Expand All @@ -85,7 +86,7 @@ impl RequestResult {
#[derive(Clone)]
pub enum PollResult {
/// Connection failure - retry if you think it's worth it
Error(hyper::HttpError),
Error(Rc<hyper::HttpError>),
/// See `PollInformation`
AuthorizationPending(PollInformation),
/// indicates we are expired, including the expiration date
Expand All @@ -98,7 +99,7 @@ pub enum PollResult {

impl Default for PollResult {
fn default() -> PollResult {
PollResult::Error(hyper::HttpError::HttpStatusError)
PollResult::Error(Rc::new(hyper::HttpError::HttpStatusError))
}
}

Expand Down Expand Up @@ -166,7 +167,7 @@ impl<C, NC> DeviceFlow<C, NC>
.body(req.as_slice())
.send() {
Err(err) => {
return RequestResult::Error(err);
return RequestResult::Error(Rc::new(err));
}
Ok(mut res) => {

Expand Down Expand Up @@ -266,7 +267,7 @@ impl<C, NC> DeviceFlow<C, NC>
.body(req.as_slice())
.send() {
Err(err) => {
return PollResult::Error(err);
return PollResult::Error(Rc::new(err));
}
Ok(mut res) => {
let mut json_str = String::new();
Expand Down
6 changes: 3 additions & 3 deletions src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl<D, S, C, NC> Authenticator<D, S, C, NC>
&self.secret.client_secret, scopes.iter());
match res {
RequestResult::Error(err) => {
match self.delegate.connection_error(err) {
match self.delegate.connection_error(&*err) {
Retry::Abort => return None,
Retry::After(d) => sleep(d),
}
Expand All @@ -154,7 +154,7 @@ impl<D, S, C, NC> Authenticator<D, S, C, NC>
loop {
match flow.poll_token() {
PollResult::Error(err) => {
match self.delegate.connection_error(err) {
match self.delegate.connection_error(&*err) {
Retry::Abort => return None,
Retry::After(d) => sleep(d),
}
Expand Down Expand Up @@ -269,7 +269,7 @@ pub trait AuthenticatorDelegate {
/// Called whenever there is an HttpError, usually if there are network problems.
///
/// Return retry information.
fn connection_error(&mut self, hyper::HttpError) -> Retry {
fn connection_error(&mut self, &hyper::HttpError) -> Retry {
Retry::Abort
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(old_io, std_misc, core, hash)]
#![feature(old_io, std_misc, core)]
#![allow(deprecated)]
//! This library can be used to acquire oauth2.0 authentication for services.
//! At the time of writing, only one way of doing so is implemented, the [device flow](https://developers.google.com/youtube/v3/guides/authentication#devices), along with a flow
Expand Down Expand Up @@ -68,11 +68,11 @@ extern crate hyper;
#[macro_use]
extern crate log;
#[cfg(test)] #[macro_use]
extern crate "yup-hyper-mock" as hyper_mock;
extern crate yup_hyper_mock as hyper_mock;
extern crate mime;
extern crate url;
extern crate itertools;
extern crate "rustc-serialize" as rustc_serialize;
extern crate rustc_serialize as rustc_serialize;


mod device;
Expand Down

0 comments on commit 2489b81

Please sign in to comment.