pub fn provide_credentials_fn<'c, T, F>(f: T) -> ProvideCredentialsFn<'c, T>
where T: Fn() -> F + Send + Sync + 'c, F: Future<Output = Result> + Send + 'static,
Expand description

Returns a new credentials provider built with the given closure. This allows you to create an ProvideCredentials implementation from an async block that returns a crate::provider::Result.

§Examples

use aws_credential_types::Credentials;
use aws_credential_types::credential_fn::provide_credentials_fn;

async fn load_credentials() -> Credentials {
    todo!()
}

provide_credentials_fn(|| async {
    // Async process to retrieve credentials goes here
    let credentials = load_credentials().await;
    Ok(credentials)
});