From 39fe5f1d25eaeadad4578392acf0e76ee03ca374 Mon Sep 17 00:00:00 2001 From: Lewin Bormann Date: Wed, 12 Jun 2019 00:05:32 +0200 Subject: [PATCH] chore(syntax): Use `dyn` everywhere and remove unused imports. --- src/installed.rs | 7 ++++--- src/service_account.rs | 9 ++++++--- src/types.rs | 11 +++++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/installed.rs b/src/installed.rs index d1497d7..2460770 100644 --- a/src/installed.rs +++ b/src/installed.rs @@ -153,7 +153,7 @@ impl<'c, C: 'c + hyper::client::connect::Connect> InstalledFlow { Err(e) => { return Err(Box::new(e) as Box); } - Ok(tok) => Ok(tok) as Result>, + Ok(tok) => Ok(tok) as Result>, } }) }) @@ -341,14 +341,15 @@ impl std::ops::Drop for InstalledFlowServer { pub struct InstalledFlowHandlerResponseFuture { inner: Box< - futures::Future, Error = hyper::http::Error> + Send, + dyn futures::Future, Error = hyper::http::Error> + Send, >, } impl InstalledFlowHandlerResponseFuture { fn new( fut: Box< - futures::Future, Error = hyper::http::Error> + Send, + dyn futures::Future, Error = hyper::http::Error> + + Send, >, ) -> Self { Self { inner: fut } diff --git a/src/service_account.rs b/src/service_account.rs index 037c3e6..bd5334b 100644 --- a/src/service_account.rs +++ b/src/service_account.rs @@ -46,7 +46,7 @@ fn encode_base64>(s: T) -> String { base64::encode_config(s.as_ref(), base64::URL_SAFE) } -fn decode_rsa_key(pem_pkcs8: &str) -> Result> { +fn decode_rsa_key(pem_pkcs8: &str) -> Result> { let private = pem_pkcs8.to_string().replace("\\n", "\n").into_bytes(); let mut private_reader: &[u8] = private.as_ref(); let private_keys = pemfile::pkcs8_private_keys(&mut private_reader); @@ -121,7 +121,7 @@ impl JWT { head } - fn sign(&self, private_key: &str) -> Result> { + fn sign(&self, private_key: &str) -> Result> { let mut jwt_head = self.encode_claims(); let key = decode_rsa_key(private_key)?; let signing_key = sign::RSASigningKey::new(&key) @@ -236,7 +236,10 @@ where } } - fn request_token(&mut self, scopes: &Vec<&str>) -> result::Result> { + fn request_token( + &mut self, + scopes: &Vec<&str>, + ) -> result::Result> { let mut claims = init_claims_from_key(&self.key, scopes); claims.sub = self.sub.clone(); let signed = JWT::new(claims).sign(self.key.private_key.as_ref().unwrap())?; diff --git a/src/types.rs b/src/types.rs index ca039b3..be16f88 100644 --- a/src/types.rs +++ b/src/types.rs @@ -4,7 +4,7 @@ use std::error::Error; use std::fmt; use std::str::FromStr; -use futures::{future, prelude::*}; +use futures::prelude::*; /// A marker trait for all Flows pub trait Flow { @@ -101,8 +101,8 @@ impl StringError { } } -impl<'a> From<&'a Error> for StringError { - fn from(err: &'a Error) -> StringError { +impl<'a> From<&'a dyn Error> for StringError { + fn from(err: &'a dyn Error) -> StringError { StringError::new(err.description().to_string(), None) } } @@ -185,7 +185,10 @@ impl FromStr for Scheme { /// The `api_key()` method is an alternative in case there are no scopes or /// if no user is involved. pub trait GetToken { - fn token<'b, I, T>(&mut self, scopes: I) -> Box>> + fn token<'b, I, T>( + &mut self, + scopes: I, + ) -> Box>> where T: AsRef + Ord + 'b, I: IntoIterator;