From 727c1d801b4ae8f7b7cb80050139926bbcb9bf48 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 26 Apr 2015 21:13:45 +0200 Subject: [PATCH] fix(rustup): replace sleep with sleep_ms Now it works with the latest compiler. I wonder why I didn't notice that before ... . --- Cargo.toml | 2 +- examples/auth.rs | 6 +++--- src/helper.rs | 16 ++++++++-------- src/lib.rs | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4b495192e..670f3eae2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "yup-oauth2" -version = "0.3.8" +version = "0.3.9" 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 12e53e4ec..867ba8b2b 100644 --- a/examples/auth.rs +++ b/examples/auth.rs @@ -1,4 +1,4 @@ -#![feature(collections, thread_sleep, std_misc, exit_status)] +#![feature(collections, std_misc, exit_status)] #![allow(deprecated)] extern crate yup_oauth2 as oauth2; extern crate yup_hyper_mock as mock; @@ -13,7 +13,7 @@ use getopts::{HasArg,Options,Occur,Fail}; use std::env; use std::default::Default; use std::time::Duration; -use std::thread::sleep; +use std::thread::sleep_ms; fn usage(program: &str, opts: &Options, err: Option) { @@ -72,7 +72,7 @@ fn main() { pi.user_code, pi.verification_url, pi.expires_at.with_timezone(&Local)); let delay = Duration::seconds(5); println!("Browser opens automatically in {} seconds", delay); - sleep(delay); + sleep_ms(delay.num_milliseconds() as u32); open::that(&pi.verification_url).ok(); println!("DONE - waiting for authorization ..."); } diff --git a/src/helper.rs b/src/helper.rs index 8f48a314e..58618cbd7 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -2,7 +2,7 @@ use std::iter::IntoIterator; use std::borrow::BorrowMut; use std::collections::HashMap; use std::hash::{SipHasher, Hash, Hasher}; -use std::thread::sleep; +use std::thread::sleep_ms; use std::cmp::min; use std::error::Error; use std::fmt; @@ -203,7 +203,7 @@ impl Authenticator RequestError::HttpError(err) => { match self.delegate.connection_error(&err) { Retry::Abort|Retry::Skip => return Err(Box::new(StringError::from(&err as &Error))), - Retry::After(d) => sleep(d), + Retry::After(d) => sleep_ms(d.num_milliseconds() as u32), } }, RequestError::InvalidClient @@ -234,7 +234,7 @@ impl Authenticator match self.delegate.connection_error(err) { Retry::Abort|Retry::Skip => return Err(Box::new(StringError::from(err as &Error))), - Retry::After(d) => sleep(d), + Retry::After(d) => sleep_ms(d.num_milliseconds() as u32), } }, &&PollError::Expired(ref t) => { @@ -251,7 +251,7 @@ impl Authenticator match self.delegate.pending(&pi) { Retry::Abort|Retry::Skip => return Err(Box::new(StringError::new("Pending authentication aborted".to_string(), None))), - Retry::After(d) => sleep(min(d, pi.interval)), + Retry::After(d) => sleep_ms(min(d, pi.interval).num_milliseconds() as u32), }, Ok(Some(token)) => return Ok(token) } @@ -301,7 +301,7 @@ impl GetToken for Authenticator return Err(Box::new(StringError::new( err.description().to_string(), None))), - Retry::After(d) => sleep(d), + Retry::After(d) => sleep_ms(d.num_milliseconds() as u32), } }, RefreshResult::RefreshError(ref err_str, ref err_description) => { @@ -322,7 +322,7 @@ impl GetToken for Authenticator Retry::Skip => break, Retry::Abort => return Err(Box::new(err)), Retry::After(d) => { - sleep(d); + sleep_ms(d.num_milliseconds() as u32); continue; } } @@ -351,7 +351,7 @@ impl GetToken for Authenticator Retry::Skip => break, Retry::Abort => return Err(Box::new(err)), Retry::After(d) => { - sleep(d); + sleep_ms(d.num_milliseconds() as u32); continue; } } @@ -367,7 +367,7 @@ impl GetToken for Authenticator match self.delegate.token_storage_failure(false, &err) { Retry::Abort|Retry::Skip => Err(Box::new(err)), Retry::After(d) => { - sleep(d); + sleep_ms(d.num_milliseconds() as u32); continue } } diff --git a/src/lib.rs b/src/lib.rs index a5f8acdec..f0cd7d5ca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(std_misc, thread_sleep)] +#![feature(std_misc)] #![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