Rusoto: Allow requests to be constructed with a builder pattern

Created on 15 Aug 2018  路  3Comments  路  Source: rusoto/rusoto

https://github.com/rusoto/rusoto/pull/789 gave us an idea on what a builder pattern looks like for requests. This is something that'd be nice to have for ergonomics.

Code like

let upload_request = PutObjectRequest {
  bucket: bucket.to_owned(),
  key: dest_filename.to_owned(),
  body: Some(contents.into()),
.  .Default::default()
};

Could be written something like this:

let mut upload_req_builder = PutObjectRequest::new()
  .bucket(bucket)
  .key(dest_filename)
  .body(contents);
enhancement help wanted

Most helpful comment

2 cent suggestion. Can the builder interfaces be made flexible I terms of the types they accept. If this is issue is about improving ergonomics, I'd love not to have to call to_owned to_string into everywhere. Rather I'd like interfaces that take generic Into types.

All 3 comments

2 cent suggestion. Can the builder interfaces be made flexible I terms of the types they accept. If this is issue is about improving ergonomics, I'd love not to have to call to_owned to_string into everywhere. Rather I'd like interfaces that take generic Into types.

This caught my attention and may be of interest. https://vfoley.xyz/rust-compile-speed-tips/ it maybe useful to consider feature flagging builder impls for the sake of compile times. Aws apis are pretty big. There could be a compile time tax for the convenience not everyone wants.

Yes, taking generic Into types is what we want and is what the PR implemented. I transcribed it in a hurry and incorrectly.

Feature flags sound good. The project will have to pay the time cost in TravisCI but we don't have to force that onto crate users.

Was this page helpful?
0 / 5 - 0 ratings