Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions evaluation/case-studies/builder-provider-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ impl DefaultCredentialsChain {

This extra trait is an implementation detail that is not in the public-facing, API so it can be migrated away when support for AFIDT is introduced.

A full builder pattern example is implemented here: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=8daf7b2d5236e581f78d2c09310d09ac
A full builder pattern example is implemented here: <https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=8daf7b2d5236e581f78d2c09310d09ac>

## Send bounds

One limitation with the proposed async version of `ProvideCredentials` is the lack of a `Send` bound on the future returned by `ProvideCredentials`. This bound is enforced by the pre-AFIT version of this trait, so any futures using the builder will not be `Send` after AFIT migration.

To fix this, we could use a return type bound[^2] on the `with_custom_credential_source` builder method:

[^2]: https://smallcultfollowing.com/babysteps/blog/2023/02/13/return-type-notation-send-bounds-part-2/
[^2]: <https://smallcultfollowing.com/babysteps/blog/2023/02/13/return-type-notation-send-bounds-part-2/>

```rust
impl DefaultCredentialsChain {
Expand Down Expand Up @@ -157,10 +157,10 @@ impl<T: async(Send) ProvideCredentials> ProvideCredentialsDyn for T {
## Usages

The SDK uses this same idiom several times:
* `ProvideCredentials`: https://docs.rs/aws-credential-types/0.54.1/aws_credential_types/provider/trait.ProvideCredentials.html
* `AsyncSleep`: https://docs.rs/aws-smithy-async/0.54.3/aws_smithy_async/rt/sleep/trait.AsyncSleep.html
* `ProvideRegion`: https://docs.rs/aws-config/0.54.1/aws_config/meta/region/trait.ProvideRegion.html
* `ProvideCredentials`: <https://docs.rs/aws-credential-types/0.54.1/aws_credential_types/provider/trait.ProvideCredentials.html>
* `AsyncSleep`: <https://docs.rs/aws-smithy-async/0.54.3/aws_smithy_async/rt/sleep/trait.AsyncSleep.html>
* `ProvideRegion`: <https://docs.rs/aws-config/0.54.1/aws_config/meta/region/trait.ProvideRegion.html>

## Future improvements

With AFIDT, we can drop the `ProvideCredentialsDyn` trait and just use `Box<dyn ProvideCredentials>` as is. Refactoring the API to use AFIDT is a totally internal-facing change.
With AFIDT, we can drop the `ProvideCredentialsDyn` trait and just use `Box<dyn ProvideCredentials>` as is. Refactoring the API to use AFIDT is a totally internal-facing change.