Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_foo() -> &Option<Foo> accessors for builders and fluent builders. #2792

Merged
merged 7 commits into from
Jun 21, 2023

Conversation

DavidSouther
Copy link
Contributor

@DavidSouther DavidSouther commented Jun 20, 2023

This allows testing, as well as making decisions while creating builders. The references are not mutable, so these props remain read only keeping the Builder invariants.

Motivation and Context

Some operations are built up using various logic (for instance, choosing an S3 bucket based on a logged in user). It is a lot of overhead to test at the mock level, and the Debug formatting is typically not stable.

Closes #2791

Description

  1. Add get_foo(&self) -> &Option<Foo> to Builders
  2. Add as_input(&self) -> &OperationInputBuilder to Fluent Builders
  3. Add get_foo(&self) -> &Option<Foo> to FluentBuilder which delegates to Builders

Testing

Included unit tests, as well as proof of concept tests

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the smithy-rs codegen or runtime crates
  • I have updated CHANGELOG.next.toml if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@DavidSouther DavidSouther requested review from a team as code owners June 20, 2023 03:26
@DavidSouther DavidSouther force-pushed the dev/builder/inner_getter branch 2 times, most recently from 5f289cd to 5a0c721 Compare June 20, 2023 03:27
@DavidSouther DavidSouther force-pushed the dev/builder/inner_getter branch from 2fb6e93 to 14647fa Compare June 20, 2023 23:38
…ers.

This allows testing, as well as making decisions while creating builders.
The references are not mutable, so these props remain read only keeping the Builder invariants.
Copy link
Collaborator

@jdisanti jdisanti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@jdisanti jdisanti enabled auto-merge June 21, 2023 23:06
@jdisanti jdisanti added this pull request to the merge queue Jun 21, 2023
Merged via the queue into smithy-lang:main with commit e6293b2 Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Accessors to Builders
2 participants