diff --git a/src/authenticator.rs b/src/authenticator.rs index 97e6ddb..f7016be 100644 --- a/src/authenticator.rs +++ b/src/authenticator.rs @@ -34,7 +34,7 @@ struct AuthenticatorImpl< /// A trait implemented for any hyper::Client as well as teh DefaultHyperClient. pub trait HyperClientBuilder { - type Connector: hyper::client::connect::Connect; + type Connector: hyper::client::connect::Connect + 'static; fn build_hyper_client(self) -> hyper::Client; } @@ -53,7 +53,7 @@ impl HyperClientBuilder for DefaultHyperClient { impl HyperClientBuilder for hyper::Client where - C: hyper::client::connect::Connect, + C: hyper::client::connect::Connect + 'static, { type Connector = C; @@ -72,12 +72,7 @@ pub trait AuthFlow { /// An authenticator can be used with `InstalledFlow`'s or `DeviceFlow`'s and /// will refresh tokens as they expire as well as optionally persist tokens to /// disk. -pub struct Authenticator< - T: AuthFlow, - S: TokenStorage, - AD: AuthenticatorDelegate, - C: HyperClientBuilder, -> { +pub struct Authenticator { client: C, token_getter: T, store: io::Result, @@ -125,7 +120,7 @@ where hyper_client: hyper::Client, ) -> Authenticator> where - NewC: hyper::client::connect::Connect, + NewC: hyper::client::connect::Connect + 'static, T: AuthFlow, { Authenticator { @@ -166,10 +161,8 @@ where /// Create the authenticator. pub fn build(self) -> io::Result where - T::TokenGetter: 'static + GetToken, - S: 'static, - AD: 'static, - C::Connector: 'static + hyper::client::connect::Connect, + T::TokenGetter: GetToken, + C::Connector: hyper::client::connect::Connect + 'static, { let client = self.client.build_hyper_client(); let store = self.store?; @@ -186,10 +179,10 @@ where impl AuthenticatorImpl where - GT: 'static + GetToken, - S: 'static + TokenStorage, - AD: 'static + AuthenticatorDelegate, - C: 'static + hyper::client::connect::Connect, + GT: GetToken, + S: TokenStorage, + AD: AuthenticatorDelegate, + C: hyper::client::connect::Connect + 'static, { async fn get_token(&self, scopes: &[T]) -> Result where @@ -266,10 +259,10 @@ where impl GetToken for AuthenticatorImpl where - GT: 'static + GetToken, - S: 'static + TokenStorage, - AD: 'static + AuthenticatorDelegate, - C: 'static + hyper::client::connect::Connect, + GT: GetToken, + S: TokenStorage, + AD: AuthenticatorDelegate, + C: hyper::client::connect::Connect + 'static, { /// Returns the API Key of the inner flow. fn api_key(&self) -> Option { diff --git a/src/device.rs b/src/device.rs index 2346e1a..51d97b3 100644 --- a/src/device.rs +++ b/src/device.rs @@ -69,7 +69,7 @@ impl DeviceFlow { impl crate::authenticator::AuthFlow for DeviceFlow where - FD: FlowDelegate + 'static, + FD: FlowDelegate, C: hyper::client::connect::Connect + 'static, { type TokenGetter = DeviceFlowImpl; @@ -97,7 +97,7 @@ pub struct DeviceFlowImpl { impl GetToken for DeviceFlowImpl where - FD: FlowDelegate + 'static, + FD: FlowDelegate, C: hyper::client::connect::Connect + 'static, { fn token<'a, T>( @@ -120,9 +120,7 @@ where impl DeviceFlowImpl where C: hyper::client::connect::Connect + 'static, - C::Transport: 'static, - C::Future: 'static, - FD: FlowDelegate + 'static, + FD: FlowDelegate, { /// Essentially what `GetToken::token` does: Retrieve a token for the given scopes without /// caching. diff --git a/src/installed.rs b/src/installed.rs index d31ea38..5dc19ed 100644 --- a/src/installed.rs +++ b/src/installed.rs @@ -53,7 +53,7 @@ where impl GetToken for InstalledFlowImpl where - FD: FlowDelegate + 'static, + FD: FlowDelegate, C: hyper::client::connect::Connect + 'static, { fn token<'a, T>( @@ -76,8 +76,8 @@ where /// The InstalledFlow implementation. pub struct InstalledFlowImpl where - FD: FlowDelegate + 'static, - C: hyper::client::connect::Connect + 'static, + FD: FlowDelegate, + C: hyper::client::connect::Connect, { method: InstalledFlowReturnMethod, client: hyper::client::Client, @@ -98,7 +98,7 @@ pub enum InstalledFlowReturnMethod { /// InstalledFlowImpl provides tokens for services that follow the "Installed" OAuth flow. (See /// https://www.oauth.com/oauth2-servers/authorization/, /// https://developers.google.com/identity/protocols/OAuth2InstalledApp). -pub struct InstalledFlow { +pub struct InstalledFlow { method: InstalledFlowReturnMethod, flow_delegate: FD, appsecret: ApplicationSecret, @@ -134,7 +134,7 @@ where impl crate::authenticator::AuthFlow for InstalledFlow where - FD: FlowDelegate + 'static, + FD: FlowDelegate, C: hyper::client::connect::Connect + 'static, { type TokenGetter = InstalledFlowImpl; @@ -151,7 +151,7 @@ where impl InstalledFlowImpl where - FD: FlowDelegate + 'static, + FD: FlowDelegate, C: hyper::client::connect::Connect + 'static, { /// Handles the token request flow; it consists of the following steps: diff --git a/src/refresh.rs b/src/refresh.rs index 6c94c67..7b33269 100644 --- a/src/refresh.rs +++ b/src/refresh.rs @@ -29,7 +29,7 @@ impl RefreshFlow { /// /// # Examples /// Please see the crate landing page for an example. - pub async fn refresh_token( + pub async fn refresh_token( client: &hyper::Client, client_secret: &ApplicationSecret, refresh_token: &str, diff --git a/src/service_account.rs b/src/service_account.rs index ebe938f..2c4cb3f 100644 --- a/src/service_account.rs +++ b/src/service_account.rs @@ -205,7 +205,6 @@ impl ServiceAccountAccess { impl ServiceAccountAccess where C: HyperClientBuilder, - C::Connector: 'static, { /// Use the provided hyper client. pub fn hyper_client(