Unverified Commit 1e27efe0 authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Make a minor optimization to `AuthOptionResolver` (#2557)

parent eff74374
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
use crate::client::orchestrator::{
    AuthOptionResolver, AuthOptionResolverParams, BoxError, HttpAuthOption,
};
use std::borrow::Cow;

/// New-type around a `Vec<HttpAuthOption>` that implements `AuthOptionResolver`.
///
@@ -23,11 +24,11 @@ impl AuthOptionListResolver {
}

impl AuthOptionResolver for AuthOptionListResolver {
    fn resolve_auth_options(
        &self,
    fn resolve_auth_options<'a>(
        &'a self,
        _params: &AuthOptionResolverParams,
    ) -> Result<Vec<HttpAuthOption>, BoxError> {
        Ok(self.auth_options.clone())
    ) -> Result<Cow<'a, [HttpAuthOption]>, BoxError> {
        Ok(Cow::Borrowed(&self.auth_options))
    }
}

+7 −6
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ use crate::type_erasure::{TypeErasedBox, TypedBox};
use aws_smithy_http::body::SdkBody;
use aws_smithy_http::property_bag::PropertyBag;
use std::any::Any;
use std::borrow::Cow;
use std::fmt::Debug;
use std::future::Future;
use std::pin::Pin;
@@ -72,17 +73,17 @@ impl AuthOptionResolverParams {
}

pub trait AuthOptionResolver: Send + Sync + Debug {
    fn resolve_auth_options(
        &self,
    fn resolve_auth_options<'a>(
        &'a self,
        params: &AuthOptionResolverParams,
    ) -> Result<Vec<HttpAuthOption>, BoxError>;
    ) -> Result<Cow<'a, [HttpAuthOption]>, BoxError>;
}

impl AuthOptionResolver for Box<dyn AuthOptionResolver> {
    fn resolve_auth_options(
        &self,
    fn resolve_auth_options<'a>(
        &'a self,
        params: &AuthOptionResolverParams,
    ) -> Result<Vec<HttpAuthOption>, BoxError> {
    ) -> Result<Cow<'a, [HttpAuthOption]>, BoxError> {
        (**self).resolve_auth_options(params)
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ pub(super) async fn orchestrate_auth(
        .map_err(construction_failure)?;
    let identity_resolvers = cfg.identity_resolvers();

    for option in auth_options {
    for option in auth_options.as_ref() {
        let scheme_id = option.scheme_id();
        let scheme_properties = option.properties();
        if let Some(auth_scheme) = cfg.http_auth_schemes().scheme(scheme_id) {