awslabs / awslabs/aws-sdk-rust
Support passing `model` builders directly as parameters
- Dominant language
- Rust
- Stars
- 3.3k
- Forks
- 290
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 3
Description
### Describe the feature
Currently, calling a method that accepts a `model` struct requires first constructing the builder (`ModelStruct::builder()`), then calling methods on it, then calling `.build()` at the end. I'd love to leave off the `.build()` and have the method accepting the structure handle that, reducing boilerplate in the common case of constructing such a model struct and immediately passing it.
### Use Case
Consider the following code:
```rust
let reservation = self
.ec2
.run_instances()
.launch_template(
aws_sdk_ec2::model::LaunchTemplateSpecification::builder()
.launch_template_name(launch_template_name)
.build(),
)
.instance_type(instance_type.clone())
/* ... */
.send()
.instrument(info_span!("RunInstances"))
.await?;
```
If `LaunchTemplateSpecification` implemented `From`, and `launch_template` accepted `impl Into`, that would allow leaving off the `.build()`.
### Proposed Solution
_No response_
### Other Information
_No response_
### Acknowledgements
- [ ] I may be able to implement this feature request
- [X] This feature might incur a breaking change
### A note for the community
### Community Note
* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue, please leave a comment
Contributor guide
Research direction
Start with the LaunchTemplateSpecification::builder() and the launch_template parameter shown in the example, then trace how model builders and generated method parameters are defined. Determine the scope of supporting From and impl Into across the SDK, and confirm that the resulting API remains compatible with the intended usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100