Function aws_config::meta::credentials::provide_credentials_fn
source · 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 credentials::Result
.
Examples
use aws_types::Credentials;
use aws_config::meta::credentials::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)
});