From 9fc24d41a28409bc12be3feb15b243182f8f27ea Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Tue, 22 Feb 2022 18:08:06 -0800 Subject: [PATCH 1/2] Make `rustls` and `native_tls` client builder helpers dyn --- .../aws-smithy-client/src/hyper_ext.rs | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/rust-runtime/aws-smithy-client/src/hyper_ext.rs b/rust-runtime/aws-smithy-client/src/hyper_ext.rs index 6d0bb6c4e9..97733c7600 100644 --- a/rust-runtime/aws-smithy-client/src/hyper_ext.rs +++ b/rust-runtime/aws-smithy-client/src/hyper_ext.rs @@ -304,19 +304,22 @@ where #[cfg(feature = "rustls")] impl ClientBuilder<(), M, R> { - /// Connect to the service over HTTPS using Rustls. - pub fn rustls(self) -> ClientBuilder, M, R> { - self.connector(Adapter::builder().build(crate::conns::https())) + /// Connect to the service over HTTPS using Rustls using dynamic dispatch. + pub fn rustls(self) -> ClientBuilder { + self.connector(DynConnector::new( + Adapter::builder().build(crate::conns::https()), + )) } } #[cfg(feature = "native-tls")] impl ClientBuilder<(), M, R> { - /// Connect to the service over HTTPS using the native TLS library on your platform. - pub fn native_tls( - self, - ) -> ClientBuilder>, M, R> { - self.connector(Adapter::builder().build(crate::conns::native_tls())) + /// Connect to the service over HTTPS using the native TLS library on your + /// platform using dynamic dispatch. + pub fn native_tls(self) -> ClientBuilder { + self.connector(DynConnector::new( + Adapter::builder().build(crate::conns::native_tls()), + )) } } @@ -632,8 +635,18 @@ mod test { use aws_smithy_http::body::SdkBody; + use super::ClientBuilder; + use crate::erase::DynConnector; use crate::hyper_ext::Adapter; + #[test] + fn builder_connection_helpers_are_dyn() { + #[cfg(feature = "rustls")] + let _builder: ClientBuilder = ClientBuilder::new().rustls(); + #[cfg(feature = "native-tls")] + let _builder: ClientBuilder = ClientBuilder::new().native_tls(); + } + #[tokio::test] async fn hyper_io_error() { let connector = TestConnection { From 28f61bd9a93c74542a1349b4f746b482635f7fea Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Tue, 22 Feb 2022 18:22:21 -0800 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.next.toml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 9e6c415d4d..98ea6e006d 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -34,3 +34,15 @@ message = "`aws_smithy_types::primitive::Encoder` is now a struct rather than an references = ["smithy-rs#1209"] meta = { "breaking" = true, "tada" = false, "bug" = false } author = "jdisanti" + +[[smithy-rs]] +message = "`ClientBuilder` helpers `rustls()` and `native_tls()` now return `DynConnector` and use dynamic dispatch rather than returning their concrete connector type that would allow static dispatch. If static dispatch is desired, then manually construct a connector to give to the builder. For example, for rustls: `builder.connector(Adapter::builder().build(aws_smithy_client::conns::https()))` (where `Adapter` is in `aws_smithy_client::hyper_ext`)." +references = ["smithy-rs#1217"] +meta = { "breaking" = true, "tada" = false, "bug" = false } +author = "jdisanti" + +[[aws-sdk-rust]] +message = "`ClientBuilder` helpers `rustls()` and `native_tls()` now return `DynConnector` so that they once again work when constructing clients with custom middleware in the SDK." +references = ["smithy-rs#1217", "aws-sdk-rust#467"] +meta = { "breaking" = false, "tada" = false, "bug" = true } +author = "jdisanti"