Download codex-rs/aws-auth/src/config.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/aws-auth/src/config.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/aws-auth/src/config.rs
-
curl -L -o config.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/aws-auth/src/config.rs
1.15 kB
| use aws_config::BehaviorVersion; | |
| use aws_config::SdkConfig; | |
| use aws_credential_types::provider::SharedCredentialsProvider; | |
| use aws_types::region::Region; | |
| use crate::AwsAuthConfig; | |
| use crate::AwsAuthError; | |
| pub(crate) async fn load_sdk_config(config: &AwsAuthConfig) -> Result<SdkConfig, AwsAuthError> { | |
| if config.service.trim().is_empty() { | |
| return Err(AwsAuthError::EmptyService); | |
| } | |
| let mut loader = aws_config::defaults(BehaviorVersion::latest()); | |
| if let Some(profile) = config.profile.as_ref() { | |
| loader = loader.profile_name(profile); | |
| } | |
| if let Some(region) = config.region.as_ref() { | |
| loader = loader.region(Region::new(region.clone())); | |
| } | |
| Ok(loader.load().await) | |
| } | |
| pub(crate) fn credentials_provider( | |
| sdk_config: &SdkConfig, | |
| ) -> Result<SharedCredentialsProvider, AwsAuthError> { | |
| sdk_config | |
| .credentials_provider() | |
| .ok_or(AwsAuthError::MissingCredentialsProvider) | |
| } | |
| pub(crate) fn resolved_region(sdk_config: &SdkConfig) -> Result<String, AwsAuthError> { | |
| sdk_config | |
| .region() | |
| .map(ToString::to_string) | |
| .ok_or(AwsAuthError::MissingRegion) | |
| } | |