kube::client

Trait ConfigExt

source
pub trait ConfigExt: Sealed {
    // Required methods
    fn base_uri_layer(&self) -> BaseUriLayer;
    fn auth_layer(&self) -> Result<Option<AuthLayer>, Error>;
    fn extra_headers_layer(&self) -> Result<ExtraHeadersLayer, Error>;
    fn rustls_https_connector(
        &self,
    ) -> Result<HttpsConnector<HttpConnector>, Error>;
    fn rustls_https_connector_with_connector<H>(
        &self,
        connector: H,
    ) -> Result<HttpsConnector<H>, Error>;
    fn rustls_client_config(&self) -> Result<ClientConfig, Error>;
    fn openssl_https_connector(
        &self,
    ) -> Result<HttpsConnector<HttpConnector>, Error>;
    fn openssl_https_connector_with_connector<H>(
        &self,
        connector: H,
    ) -> Result<HttpsConnector<H>, Error>
       where H: Service<Uri> + Send,
             <H as Service<Uri>>::Error: Into<Box<dyn Error + Send + Sync>>,
             <H as Service<Uri>>::Future: Send + 'static,
             <H as Service<Uri>>::Response: Read + Write + Connection + Unpin;
    fn openssl_ssl_connector_builder(
        &self,
    ) -> Result<SslConnectorBuilder, Error>;
}
Available on crate feature 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§

source

fn base_uri_layer(&self) -> BaseUriLayer

Layer to set the base URI of requests to the configured server.

source

fn auth_layer(&self) -> Result<Option<AuthLayer>, Error>

Optional layer to set up Authorization header depending on the config.

source

fn extra_headers_layer(&self) -> Result<ExtraHeadersLayer, Error>

Layer to add non-authn HTTP headers depending on the config.

source

fn rustls_https_connector(&self) -> Result<HttpsConnector<HttpConnector>, Error>

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);
source

fn rustls_https_connector_with_connector<H>( &self, connector: H, ) -> Result<HttpsConnector<H>, Error>

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);
source

fn rustls_client_config(&self) -> Result<ClientConfig, Error>

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))
};
source

fn openssl_https_connector( &self, ) -> Result<HttpsConnector<HttpConnector>, Error>

Create [hyper_openssl::HttpsConnector] based on config.

§Example
let config = Config::infer().await?;
let https = config.openssl_https_connector()?;
source

fn openssl_https_connector_with_connector<H>( &self, connector: H, ) -> Result<HttpsConnector<H>, Error>
where H: Service<Uri> + Send, <H as Service<Uri>>::Error: Into<Box<dyn Error + Send + Sync>>, <H as Service<Uri>>::Future: Send + 'static, <H as Service<Uri>>::Response: Read + Write + Connection + Unpin,

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)?;
source

fn openssl_ssl_connector_builder(&self) -> Result<SslConnectorBuilder, Error>

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)?
};

Object Safety§

This trait is not object safe.

Implementors§