Remove unnecessary 'static bounds

This commit is contained in:
Glenn Griffin
2019-11-11 13:11:16 -08:00
parent e8675fa1da
commit 05f7c10533
5 changed files with 24 additions and 34 deletions

View File

@@ -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<Self::Connector>;
}
@@ -53,7 +53,7 @@ impl HyperClientBuilder for DefaultHyperClient {
impl<C> HyperClientBuilder for hyper::Client<C>
where
C: hyper::client::connect::Connect,
C: hyper::client::connect::Connect + 'static,
{
type Connector = C;
@@ -72,12 +72,7 @@ pub trait AuthFlow<C> {
/// 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<C::Connector>,
S: TokenStorage,
AD: AuthenticatorDelegate,
C: HyperClientBuilder,
> {
pub struct Authenticator<T, S, AD, C> {
client: C,
token_getter: T,
store: io::Result<S>,
@@ -125,7 +120,7 @@ where
hyper_client: hyper::Client<NewC>,
) -> Authenticator<T, S, AD, hyper::Client<NewC>>
where
NewC: hyper::client::connect::Connect,
NewC: hyper::client::connect::Connect + 'static,
T: AuthFlow<NewC>,
{
Authenticator {
@@ -166,10 +161,8 @@ where
/// Create the authenticator.
pub fn build(self) -> io::Result<impl GetToken>
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<GT, S, AD, C> AuthenticatorImpl<GT, S, AD, C>
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<T>(&self, scopes: &[T]) -> Result<Token, RequestError>
where
@@ -266,10 +259,10 @@ where
impl<GT, S, AD, C> GetToken for AuthenticatorImpl<GT, S, AD, C>
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<String> {

View File

@@ -69,7 +69,7 @@ impl<FD> DeviceFlow<FD> {
impl<FD, C> crate::authenticator::AuthFlow<C> for DeviceFlow<FD>
where
FD: FlowDelegate + 'static,
FD: FlowDelegate,
C: hyper::client::connect::Connect + 'static,
{
type TokenGetter = DeviceFlowImpl<FD, C>;
@@ -97,7 +97,7 @@ pub struct DeviceFlowImpl<FD, C> {
impl<FD, C> GetToken for DeviceFlowImpl<FD, C>
where
FD: FlowDelegate + 'static,
FD: FlowDelegate,
C: hyper::client::connect::Connect + 'static,
{
fn token<'a, T>(
@@ -120,9 +120,7 @@ where
impl<FD, C> DeviceFlowImpl<FD, C>
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.

View File

@@ -53,7 +53,7 @@ where
impl<FD, C> GetToken for InstalledFlowImpl<FD, C>
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<FD, C>
where
FD: FlowDelegate + 'static,
C: hyper::client::connect::Connect + 'static,
FD: FlowDelegate,
C: hyper::client::connect::Connect,
{
method: InstalledFlowReturnMethod,
client: hyper::client::Client<C, hyper::Body>,
@@ -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<FD: FlowDelegate + 'static> {
pub struct InstalledFlow<FD: FlowDelegate> {
method: InstalledFlowReturnMethod,
flow_delegate: FD,
appsecret: ApplicationSecret,
@@ -134,7 +134,7 @@ where
impl<FD, C> crate::authenticator::AuthFlow<C> for InstalledFlow<FD>
where
FD: FlowDelegate + 'static,
FD: FlowDelegate,
C: hyper::client::connect::Connect + 'static,
{
type TokenGetter = InstalledFlowImpl<FD, C>;
@@ -151,7 +151,7 @@ where
impl<FD, C> InstalledFlowImpl<FD, C>
where
FD: FlowDelegate + 'static,
FD: FlowDelegate,
C: hyper::client::connect::Connect + 'static,
{
/// Handles the token request flow; it consists of the following steps:

View File

@@ -29,7 +29,7 @@ impl RefreshFlow {
///
/// # Examples
/// Please see the crate landing page for an example.
pub async fn refresh_token<C: 'static + hyper::client::connect::Connect>(
pub async fn refresh_token<C: hyper::client::connect::Connect + 'static>(
client: &hyper::Client<C>,
client_secret: &ApplicationSecret,
refresh_token: &str,

View File

@@ -205,7 +205,6 @@ impl ServiceAccountAccess<DefaultHyperClient> {
impl<C> ServiceAccountAccess<C>
where
C: HyperClientBuilder,
C::Connector: 'static,
{
/// Use the provided hyper client.
pub fn hyper_client<NewC: HyperClientBuilder>(