@@ -76,9 +76,11 @@ impl Endpoint {
7676 /// # let mut builder = Endpoint::from_static("https://example.com");
7777 /// builder.timeout(Duration::from_secs(5));
7878 /// ```
79- pub fn timeout ( & mut self , dur : Duration ) -> & mut Self {
80- self . timeout = Some ( dur) ;
81- self
79+ pub fn timeout ( self , dur : Duration ) -> Self {
80+ Endpoint {
81+ timeout : Some ( dur) ,
82+ ..self
83+ }
8284 }
8385
8486 /// Apply a concurrency limit to each request.
@@ -88,9 +90,11 @@ impl Endpoint {
8890 /// # let mut builder = Endpoint::from_static("https://example.com");
8991 /// builder.concurrency_limit(256);
9092 /// ```
91- pub fn concurrency_limit ( & mut self , limit : usize ) -> & mut Self {
92- self . concurrency_limit = Some ( limit) ;
93- self
93+ pub fn concurrency_limit ( self , limit : usize ) -> Self {
94+ Endpoint {
95+ concurrency_limit : Some ( limit) ,
96+ ..self
97+ }
9498 }
9599
96100 /// Apply a rate limit to each request.
@@ -101,9 +105,11 @@ impl Endpoint {
101105 /// # let mut builder = Endpoint::from_static("https://example.com");
102106 /// builder.rate_limit(32, Duration::from_secs(1));
103107 /// ```
104- pub fn rate_limit ( & mut self , limit : u64 , duration : Duration ) -> & mut Self {
105- self . rate_limit = Some ( ( limit, duration) ) ;
106- self
108+ pub fn rate_limit ( self , limit : u64 , duration : Duration ) -> Self {
109+ Endpoint {
110+ rate_limit : Some ( ( limit, duration) ) ,
111+ ..self
112+ }
107113 }
108114
109115 /// Sets the [`SETTINGS_INITIAL_WINDOW_SIZE`][spec] option for HTTP2
@@ -112,33 +118,41 @@ impl Endpoint {
112118 /// Default is 65,535
113119 ///
114120 /// [spec]: https://http2.github.io/http2-spec/#SETTINGS_INITIAL_WINDOW_SIZE
115- pub fn initial_stream_window_size ( & mut self , sz : impl Into < Option < u32 > > ) -> & mut Self {
116- self . init_stream_window_size = sz. into ( ) ;
117- self
121+ pub fn initial_stream_window_size ( self , sz : impl Into < Option < u32 > > ) -> Self {
122+ Endpoint {
123+ init_stream_window_size : sz. into ( ) ,
124+ ..self
125+ }
118126 }
119127
120128 /// Sets the max connection-level flow control for HTTP2
121129 ///
122130 /// Default is 65,535
123- pub fn initial_connection_window_size ( & mut self , sz : impl Into < Option < u32 > > ) -> & mut Self {
124- self . init_connection_window_size = sz. into ( ) ;
125- self
131+ pub fn initial_connection_window_size ( self , sz : impl Into < Option < u32 > > ) -> Self {
132+ Endpoint {
133+ init_connection_window_size : sz. into ( ) ,
134+ ..self
135+ }
126136 }
127137
128138 /// Intercept outbound HTTP Request headers;
129- pub fn intercept_headers < F > ( & mut self , f : F ) -> & mut Self
139+ pub fn intercept_headers < F > ( self , f : F ) -> Self
130140 where
131141 F : Fn ( & mut http:: HeaderMap ) + Send + Sync + ' static ,
132142 {
133- self . interceptor_headers = Some ( Arc :: new ( f) ) ;
134- self
143+ Endpoint {
144+ interceptor_headers : Some ( Arc :: new ( f) ) ,
145+ ..self
146+ }
135147 }
136148
137149 /// Configures TLS for the endpoint.
138150 #[ cfg( feature = "tls" ) ]
139- pub fn tls_config ( & mut self , tls_config : & ClientTlsConfig ) -> & mut Self {
140- self . tls = Some ( tls_config. tls_connector ( self . uri . clone ( ) ) . unwrap ( ) ) ;
141- self
151+ pub fn tls_config ( self , tls_config : ClientTlsConfig ) -> Self {
152+ Endpoint {
153+ tls : Some ( tls_config. tls_connector ( self . uri . clone ( ) ) . unwrap ( ) ) ,
154+ ..self
155+ }
142156 }
143157
144158 /// Create a channel from this config.
@@ -262,48 +276,55 @@ impl ClientTlsConfig {
262276 ///
263277 /// This has no effect if `rustls_client_config` or `openssl_connector` is used to configure
264278 /// Rustls or OpenSSL respectively.
265- pub fn domain_name ( & mut self , domain_name : impl Into < String > ) -> & mut Self {
266- self . domain = Some ( domain_name. into ( ) ) ;
267- self
279+ pub fn domain_name ( self , domain_name : impl Into < String > ) -> Self {
280+ ClientTlsConfig {
281+ domain : Some ( domain_name. into ( ) ) ,
282+ ..self
283+ }
268284 }
269285
270286 /// Sets the CA Certificate against which to verify the server's TLS certificate.
271287 ///
272288 /// This has no effect if `rustls_client_config` or `openssl_connector` is used to configure
273289 /// Rustls or OpenSSL respectively.
274- pub fn ca_certificate ( & mut self , ca_certificate : Certificate ) -> & mut Self {
275- self . cert = Some ( ca_certificate) ;
276- self
290+ pub fn ca_certificate ( self , ca_certificate : Certificate ) -> Self {
291+ ClientTlsConfig {
292+ cert : Some ( ca_certificate) ,
293+ ..self
294+ }
277295 }
278296
279297 /// Sets the client identity to present to the server.
280298 ///
281299 /// This has no effect if `rustls_client_config` or `openssl_connector` is used to configure
282300 /// Rustls or OpenSSL respectively.
283- pub fn identity ( & mut self , identity : Identity ) -> & mut Self {
284- self . identity = Some ( identity) ;
285- self
301+ pub fn identity ( self , identity : Identity ) -> Self {
302+ ClientTlsConfig {
303+ identity : Some ( identity) ,
304+ ..self
305+ }
286306 }
287307
288308 /// Use options specified by the given `SslConnector` to configure TLS.
289309 ///
290310 /// This overrides all other TLS options set via other means.
291311 #[ cfg( feature = "openssl" ) ]
292- pub fn openssl_connector ( & mut self , connector : openssl1:: ssl:: SslConnector ) -> & mut Self {
293- self . openssl_raw = Some ( connector) ;
294- self
312+ pub fn openssl_connector ( self , connector : openssl1:: ssl:: SslConnector ) -> Self {
313+ ClientTlsConfig {
314+ openssl_raw : Some ( connector) ,
315+ ..self
316+ }
295317 }
296318
297319 /// Use options specified by the given `ClientConfig` to configure TLS.
298320 ///
299321 /// This overrides all other TLS options set via other means.
300322 #[ cfg( feature = "rustls" ) ]
301- pub fn rustls_client_config (
302- & mut self ,
303- config : tokio_rustls:: rustls:: ClientConfig ,
304- ) -> & mut Self {
305- self . rustls_raw = Some ( config) ;
306- self
323+ pub fn rustls_client_config ( self , config : tokio_rustls:: rustls:: ClientConfig ) -> Self {
324+ ClientTlsConfig {
325+ rustls_raw : Some ( config) ,
326+ ..self
327+ }
307328 }
308329
309330 fn tls_connector ( & self , uri : Uri ) -> Result < TlsConnector , crate :: Error > {
0 commit comments