aws_smithy_runtime_api/client/auth/
static_resolver.rs

1/*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6use crate::box_error::BoxError;
7use crate::client::auth::{AuthSchemeId, AuthSchemeOptionResolverParams, ResolveAuthSchemeOptions};
8use std::borrow::Cow;
9
10/// New-type around a `Vec<AuthSchemeId>` that implements `ResolveAuthSchemeOptions`.
11#[derive(Debug)]
12pub struct StaticAuthSchemeOptionResolver {
13    auth_scheme_options: Vec<AuthSchemeId>,
14}
15
16impl StaticAuthSchemeOptionResolver {
17    /// Creates a new instance of `StaticAuthSchemeOptionResolver`.
18    pub fn new(auth_scheme_options: Vec<AuthSchemeId>) -> Self {
19        Self {
20            auth_scheme_options,
21        }
22    }
23}
24
25impl ResolveAuthSchemeOptions for StaticAuthSchemeOptionResolver {
26    fn resolve_auth_scheme_options(
27        &self,
28        _params: &AuthSchemeOptionResolverParams,
29    ) -> Result<Cow<'_, [AuthSchemeId]>, BoxError> {
30        Ok(Cow::Borrowed(&self.auth_scheme_options))
31    }
32}
33
34/// Empty params to be used with [`StaticAuthSchemeOptionResolver`].
35#[derive(Debug)]
36pub struct StaticAuthSchemeOptionResolverParams;
37
38impl StaticAuthSchemeOptionResolverParams {
39    /// Creates a new `StaticAuthSchemeOptionResolverParams`.
40    pub fn new() -> Self {
41        Self
42    }
43}
44
45impl From<StaticAuthSchemeOptionResolverParams> for AuthSchemeOptionResolverParams {
46    fn from(params: StaticAuthSchemeOptionResolverParams) -> Self {
47        AuthSchemeOptionResolverParams::new(params)
48    }
49}