pub trait ConfigExt: Sealed {
// Required methods
fn base_uri_layer(&self) -> BaseUriLayer;
fn auth_layer(&self) -> Result<Option<AuthLayer>>;
fn extra_headers_layer(&self) -> Result<ExtraHeadersLayer>;
fn rustls_https_connector(&self) -> Result<HttpsConnector<HttpConnector>>;
fn rustls_https_connector_with_connector<H>(
&self,
connector: H,
) -> Result<HttpsConnector<H>>;
fn rustls_client_config(&self) -> Result<ClientConfig>;
fn openssl_https_connector(&self) -> Result<HttpsConnector<HttpConnector>>;
fn openssl_https_connector_with_connector<H>(
&self,
connector: H,
) -> Result<HttpsConnector<H>>
where H: Service<Uri> + Send,
H::Error: Into<Box<dyn Error + Send + Sync>>,
H::Future: Send + 'static,
H::Response: Read + Write + Connection + Unpin;
fn openssl_ssl_connector_builder(&self) -> Result<SslConnectorBuilder>;
}
client
only.Expand description
Extensions to Config
for custom Client
.
See Client::new
for an example.
This trait is sealed and cannot be implemented.
Required Methods§
Sourcefn base_uri_layer(&self) -> BaseUriLayer
fn base_uri_layer(&self) -> BaseUriLayer
Layer to set the base URI of requests to the configured server.
Sourcefn auth_layer(&self) -> Result<Option<AuthLayer>>
fn auth_layer(&self) -> Result<Option<AuthLayer>>
Optional layer to set up Authorization
header depending on the config.
Sourcefn extra_headers_layer(&self) -> Result<ExtraHeadersLayer>
fn extra_headers_layer(&self) -> Result<ExtraHeadersLayer>
Layer to add non-authn HTTP headers depending on the config.
Sourcefn rustls_https_connector(&self) -> Result<HttpsConnector<HttpConnector>>
Available on crate feature rustls-tls
only.
fn rustls_https_connector(&self) -> Result<HttpsConnector<HttpConnector>>
rustls-tls
only.Create hyper_rustls::HttpsConnector
based on config.
§Example
let config = Config::infer().await?;
let https = config.rustls_https_connector()?;
let hyper_client: hyper_util::client::legacy::Client<_, Body> = hyper_util::client::legacy::Client::builder(TokioExecutor::new()).build(https);
Sourcefn rustls_https_connector_with_connector<H>(
&self,
connector: H,
) -> Result<HttpsConnector<H>>
Available on crate feature rustls-tls
only.
fn rustls_https_connector_with_connector<H>( &self, connector: H, ) -> Result<HttpsConnector<H>>
rustls-tls
only.Create hyper_rustls::HttpsConnector
based on config and connector
.
§Example
let config = Config::infer().await?;
let mut connector = HttpConnector::new();
connector.enforce_http(false);
let https = config.rustls_https_connector_with_connector(connector)?;
let hyper_client: hyper_util::client::legacy::Client<_, Body> = hyper_util::client::legacy::Client::builder(TokioExecutor::new()).build(https);
Sourcefn rustls_client_config(&self) -> Result<ClientConfig>
Available on crate feature rustls-tls
only.
fn rustls_client_config(&self) -> Result<ClientConfig>
rustls-tls
only.Create rustls::ClientConfig
based on config.
§Example
let config = Config::infer().await?;
let https = {
let rustls_config = std::sync::Arc::new(config.rustls_client_config()?);
let mut http = HttpConnector::new();
http.enforce_http(false);
hyper_rustls::HttpsConnector::from((http, rustls_config))
};
Sourcefn openssl_https_connector(&self) -> Result<HttpsConnector<HttpConnector>>
Available on crate feature openssl-tls
only.
fn openssl_https_connector(&self) -> Result<HttpsConnector<HttpConnector>>
openssl-tls
only.Create [hyper_openssl::HttpsConnector
] based on config.
§Example
let config = Config::infer().await?;
let https = config.openssl_https_connector()?;
Sourcefn openssl_https_connector_with_connector<H>(
&self,
connector: H,
) -> Result<HttpsConnector<H>>
Available on crate feature openssl-tls
only.
fn openssl_https_connector_with_connector<H>( &self, connector: H, ) -> Result<HttpsConnector<H>>
openssl-tls
only.Create [hyper_openssl::HttpsConnector
] based on config and connector
.
§Example
let mut http = HttpConnector::new();
http.enforce_http(false);
let config = Config::infer().await?;
let https = config.openssl_https_connector_with_connector(http)?;
Sourcefn openssl_ssl_connector_builder(&self) -> Result<SslConnectorBuilder>
Available on crate feature openssl-tls
only.
fn openssl_ssl_connector_builder(&self) -> Result<SslConnectorBuilder>
openssl-tls
only.Create openssl::ssl::SslConnectorBuilder
based on config.
§Example
let config = Config::infer().await?;
let https = {
let mut http = HttpConnector::new();
http.enforce_http(false);
let ssl = config.openssl_ssl_connector_builder()?;
hyper_openssl::client::legacy::HttpsConnector::with_connector(http, ssl)?
};
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.