use aws_smithy_types::timeout;
use crate::environment::timeout_config::EnvironmentVariableTimeoutConfigProvider;
use crate::profile;
use crate::provider_config::ProviderConfig;
pub fn default_provider() -> Builder {
Builder::default()
}
#[derive(Debug, Default)]
pub struct Builder {
env_provider: EnvironmentVariableTimeoutConfigProvider,
profile_file: profile::timeout_config::Builder,
}
impl Builder {
pub fn configure(mut self, configuration: &ProviderConfig) -> Self {
self.env_provider =
EnvironmentVariableTimeoutConfigProvider::new_with_env(configuration.env());
self.profile_file = self.profile_file.configure(configuration);
self
}
pub fn profile_name(mut self, name: &str) -> Self {
self.profile_file = self.profile_file.profile_name(name);
self
}
pub async fn timeout_config(self) -> timeout::Config {
let builder_from_env = match self.env_provider.timeout_config() {
Ok(timeout_config_builder) => timeout_config_builder,
Err(err) => panic!("{}", err),
};
let builder_from_profile = match self.profile_file.build().timeout_config().await {
Ok(timeout_config_builder) => timeout_config_builder,
Err(err) => panic!("{}", err),
};
builder_from_env.take_unset_from(builder_from_profile)
}
}