aws_config/
env_service_config.rs

1/*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6use aws_runtime::env_config::section::EnvConfigSections;
7use aws_runtime::env_config::EnvConfigValue;
8use aws_types::os_shim_internal::Env;
9use aws_types::service_config::{LoadServiceConfig, ServiceConfigKey};
10
11#[derive(Debug)]
12pub(crate) struct EnvServiceConfig {
13    pub(crate) env: Env,
14    pub(crate) env_config_sections: EnvConfigSections,
15}
16
17impl LoadServiceConfig for EnvServiceConfig {
18    fn load_config(&self, key: ServiceConfigKey<'_>) -> Option<String> {
19        let (value, _source) = EnvConfigValue::new()
20            .env(key.env())
21            .profile(key.profile())
22            .service_id(key.service_id())
23            .load(&self.env, Some(&self.env_config_sections))?;
24
25        Some(value.to_string())
26    }
27}