fn credentials_from_environment() -> Result<AwsCredentials, CredentialsError> {
    let env_key = match non_empty_env_var(AWS_ACCESS_KEY_ID) {
        Some(val) => val,
        None => return Err(CredentialsError::new(E_NO_ACCESS_KEY_ID)),
    };
    let env_secret = match non_empty_env_var(AWS_SECRET_ACCESS_KEY) {
        Some(val) => val,
        None => {
            return Err(CredentialsError::new(E_NO_SECRET_ACCESS_KEY))
        }
    };
    // Present when using temporary credentials, e.g. on Lambda with IAM roles
    let token = non_empty_env_var(AWS_SESSION_TOKEN);
    // Mimik botocore's behavior, see https://github.com/boto/botocore/pull/1187.
    let expires_at = match non_empty_env_var(AWS_CREDENTIAL_EXPIRATION) {
        Some(val) => match DateTime::<FixedOffset>::parse_from_rfc3339(&val).map(|dt| dt.with_timezone(&Utc)) {
            Ok(e) => Some(e),
            Err(e) => return Err(CredentialsError::new(format!("{} '{}': {}", E_INVALID_EXPIRATION, val, e)))
        },
        _ => None,
    };
    Ok(AwsCredentials::new(
        env_key,
        env_secret,
        token,
        expires_at,
    ))
}
/// Grabs the Credentials from the environment.
Grabs the Credentials from the environment.
Grabs the Credentials from the environment .
fn credentials_from_environment() -> Result<AwsCredentials, CredentialsError> {
    let env_key = match non_empty_env_var(AWS_ACCESS_KEY_ID) {
        Some(val) => val,
        None => return Err(CredentialsError::new(E_NO_ACCESS_KEY_ID)),
    };
    let env_secret = match non_empty_env_var(AWS_SECRET_ACCESS_KEY) {
        Some(val) => val,
        None => {
            return Err(CredentialsError::new(E_NO_SECRET_ACCESS_KEY))
        }
    };
    // Present when using temporary credentials, e.g. on Lambda with IAM roles
    let token = non_empty_env_var(AWS_SESSION_TOKEN);
    // Mimik botocore's behavior, see https://github.com/boto/botocore/pull/1187.
    let expires_at = match non_empty_env_var(AWS_CREDENTIAL_EXPIRATION) {
        Some(val) => match DateTime::<FixedOffset>::parse_from_rfc3339(&val).map(|dt| dt.with_timezone(&Utc)) {
            Ok(e) => Some(e),
            Err(e) => return Err(CredentialsError::new(format!("{} '{}': {}", E_INVALID_EXPIRATION, val, e)))
        },
        _ => None,
    };
    Ok(AwsCredentials::new(
        env_key,
        env_secret,
        token,
        expires_at,
    ))
}
fn credentials_from_environment ( ) -> Result < AwsCredentials , CredentialsError > { let env_key = match non_empty_env_var ( AWS_ACCESS_KEY_ID ) { Some ( val ) => val , None => return Err ( CredentialsError :: new ( E_NO_ACCESS_KEY_ID ) ) , } ; let env_secret = match non_empty_env_var ( AWS_SECRET_ACCESS_KEY ) { Some ( val ) => val , None => { return Err ( CredentialsError :: new ( E_NO_SECRET_ACCESS_KEY ) ) } } ; // Present when using temporary credentials, e.g. on Lambda with IAM roles let token = non_empty_env_var ( AWS_SESSION_TOKEN ) ; // Mimik botocore's behavior, see https://github.com/boto/botocore/pull/1187. let expires_at = match non_empty_env_var ( AWS_CREDENTIAL_EXPIRATION ) { Some ( val ) => match DateTime :: < FixedOffset > :: parse_from_rfc3339 ( & val ) . map ( | dt | dt . with_timezone ( & Utc ) ) { Ok ( e ) => Some ( e ) , Err ( e ) => return Err ( CredentialsError :: new ( format ! ( " " E_INVALID_EXPIRATION val e ) ) ) } , _ => None , } ; Ok ( AwsCredentials :: new ( env_key , env_secret , token , expires_at , ) ) }
Grabs the Credentials from the environment.
Grabs the Credentials from the environment .